forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exp_test.py
65 lines (59 loc) · 2.12 KB
/
exp_test.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import unittest
from test_framework.shell import SpyShell, FakeCommand, RunResult
import os
import imp
from test_framework.git import Git
exp = imp.load_source("exp", os.path.join(os.path.dirname(__file__), "exp"))
class TestExp(unittest.TestCase):
def test_try_push_new_branch_branch_does_not_exist(self):
spy_shell = SpyShell(
[
FakeCommand(
"git rev-parse --verify exp/banana", # the branch does not exist
RunResult(1, b""),
),
FakeCommand(
"git checkout -b exp/banana", # push the branch
RunResult(0, b""),
),
FakeCommand(
"git push -f origin exp/banana", # push the branch
RunResult(0, b""),
),
FakeCommand(
"git checkout banana",
RunResult(0, b""),
),
]
)
git = Git(spy_shell)
exp.try_push_new_branch(git, "banana", "exp/banana")
spy_shell.assert_commands(self)
def test_try_push_new_branch_branch_exists(self):
spy_shell = SpyShell(
[
FakeCommand(
"git rev-parse --verify exp/banana", # the branch exists already
RunResult(0, b""),
),
FakeCommand(
"git branch -D exp/banana", # the branch exists already
RunResult(0, b""),
),
FakeCommand(
"git checkout -b exp/banana", # push the branch
RunResult(0, b""),
),
FakeCommand(
"git push -f origin exp/banana", # push the branch
RunResult(0, b""),
),
FakeCommand(
"git checkout banana",
RunResult(0, b""),
),
]
)
git = Git(spy_shell)
exp.try_push_new_branch(git, "banana", "exp/banana")
spy_shell.assert_commands(self)