summaryrefslogtreecommitdiffstats
path: root/python/mozversioncontrol/test/test_get_mozilla_remote_args.py
blob: 0d6872b642592b72d4f3e99779d1d379870b1bed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import mozunit

from mozversioncontrol import get_repository_object

STEPS = {
    "hg": [],
    "git": [
        "git remote add blah https://example.com/blah",
        """
        git remote add unified hg::https://hg.mozilla.org/mozilla-unified
        git remote add central hg::https://hg.mozilla.org/central
        git remote add try hg::https://hg.mozilla.org/try
        """,
    ],
}


def test_get_upstream_remotes(repo):
    # Test is only relevant for Git.
    if not repo.vcs == "git":
        return

    repo.execute_next_step()

    vcs = get_repository_object(repo.dir)
    remotes = vcs.get_mozilla_remote_args()

    assert remotes == [
        "--remotes"
    ], "Default `--remotes` passed without finding official remote."

    repo.execute_next_step()

    remotes = sorted(vcs.get_mozilla_remote_args())

    assert remotes == [
        "--remotes=central",
        "--remotes=unified",
    ], "Multiple non-try remote arguments should be found."


if __name__ == "__main__":
    mozunit.main()