Debian Codegraph @

python/mozversioncontrol/test/test_branch.py

raw
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 import mozunit
6
7 from mozversioncontrol import get_repository_object
8
9 STEPS = {
10 "hg": [
11 """
12 hg bookmark test
13 """,
14 """
15 echo "bar" > foo
16 hg commit -m "second commit"
17 """,
18 ],
19 "git": [
20 """
21 git checkout -b test
22 """,
23 """
24 echo "bar" > foo
25 git commit -a -m "second commit"
26 """,
27 ],
28 "jj": [],
29 }
30
31
32 def test_branch(repo):
33 vcs = get_repository_object(repo.dir)
34 if vcs.name == "jj":
35 mozunit.pytest.skip("jj does not have an active branch")
36
37 if vcs.name == "git":
38 assert vcs.branch == "master"
39 else:
40 assert vcs.branch is None
41
42 repo.execute_next_step()
43 assert vcs.branch == "test"
44
45 repo.execute_next_step()
46 assert vcs.branch == "test"
47
48 vcs.update(vcs.head_ref)
49 assert vcs.branch is None
50
51 vcs.update("test")
52 assert vcs.branch == "test"
53
54
55 if __name__ == "__main__":
56 mozunit.main()