Skip to content

Commit b280242

Browse files
committed
[conflict-mediator] Add tests
1 parent fe6b25d commit b280242

File tree

5 files changed

+78
-5
lines changed

5 files changed

+78
-5
lines changed

conflict_mediator/tests/specs/base.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@ initialization:
44
empty: true
55
message: Empty commit
66
id: start
7+
- type: new-file
8+
filename: script.py
9+
contents: |
10+
print("Hello Everyone and World!")
11+
- type: add
12+
files:
13+
- script.py
14+
- type: commit
15+
message: Fix print
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: new-file
8+
filename: script.py
9+
contents: |
10+
print("Hello World!")
11+
- type: add
12+
files:
13+
- script.py
14+
- type: commit
15+
message: No fix print
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty
6+
id: start
7+
- type: branch
8+
branch-name: bug-fix
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
initialization:
2+
steps:
3+
- type: new-file
4+
filename: test.txt
5+
contents: |
6+
hi
7+
- type: add
8+
files:
9+
- test.txt
10+
- type: commit
11+
message: Start
12+
id: start
13+
- type: edit-file
14+
filename: test.txt
15+
contents: |
16+
changed
Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
1-
from git_autograder import GitAutograderTestLoader
1+
from git_autograder import GitAutograderStatus, GitAutograderTestLoader, assert_output
22

3-
from ..verify import verify
3+
from ..verify import (
4+
MERGE_NOT_RESOLVED,
5+
NOT_ON_MAIN,
6+
RESET_MESSAGE,
7+
UNCOMMITTED_CHANGES,
8+
verify,
9+
)
410

511
REPOSITORY_NAME = "conflict-mediator"
612

713
loader = GitAutograderTestLoader(__file__, REPOSITORY_NAME, verify)
814

915

10-
def test():
11-
with loader.load("specs/base.yml", "start"):
12-
pass
16+
def test_base():
17+
with loader.load("specs/base.yml", "start") as output:
18+
assert_output(output, GitAutograderStatus.SUCCESSFUL)
19+
20+
21+
def test_no_fix():
22+
with loader.load("specs/no_fix.yml", "start") as output:
23+
assert_output(
24+
output,
25+
GitAutograderStatus.UNSUCCESSFUL,
26+
[MERGE_NOT_RESOLVED, RESET_MESSAGE],
27+
)
28+
29+
30+
def test_uncommitted():
31+
with loader.load("specs/uncommitted.yml") as output:
32+
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [UNCOMMITTED_CHANGES])
33+
34+
35+
def test_not_main():
36+
with loader.load("specs/not_main.yml") as output:
37+
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [NOT_ON_MAIN])

0 commit comments

Comments
 (0)