Skip to content

Commit acc759e

Browse files
committed
[staging-intervention] Add unit test
1 parent f074837 commit acc759e

File tree

5 files changed

+77
-5
lines changed

5 files changed

+77
-5
lines changed

staging_intervention/tests/specs/base.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ initialization:
44
empty: true
55
message: Empty commit
66
id: start
7+
- type: bash
8+
runs: |
9+
declare -a names=("josh" "adam" "mary" "jane" "charlie" "kristen" "alice" "john")
10+
for name in "${names[@]}"; do
11+
touch "$name.txt"
12+
git add "$name.txt"
13+
done
14+
git restore --staged josh.txt adam.txt mary.txt
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: bash
8+
runs: |
9+
declare -a names=("josh" "adam" "mary" "jane" "charlie" "kristen" "alice" "john")
10+
for name in "${names[@]}"; do
11+
touch "$name.txt"
12+
git add "$name.txt"
13+
done
14+
git restore --staged josh.txt adam.txt mary.txt kristen.txt john.txt
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: bash
8+
runs: |
9+
declare -a names=("josh" "adam" "mary" "jane" "charlie" "kristen" "alice" "john")
10+
for name in "${names[@]}"; do
11+
touch "$name.txt"
12+
git add "$name.txt"
13+
done
14+
git restore --staged josh.txt adam.txt
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: bash
8+
runs: |
9+
declare -a names=("josh" "adam" "mary" "jane" "charlie" "kristen" "alice" "john")
10+
for name in "${names[@]}"; do
11+
touch "$name.txt"
12+
git add "$name.txt"
13+
done
14+
git restore --staged josh.txt adam.txt alice.txt
Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
1-
from git_autograder import GitAutograderTestLoader
1+
from git_autograder import GitAutograderTestLoader, assert_output
2+
from git_autograder.status import GitAutograderStatus
23

3-
from ..verify import verify
4+
from ..verify import EXTRA_FILES_UNSTAGED, MISSING_FILES_UNSTAGED, verify
45

56
REPOSITORY_NAME = "staging-intervention"
67

78
loader = GitAutograderTestLoader(__file__, REPOSITORY_NAME, verify)
89

910

10-
def test():
11-
with loader.load("specs/base.yml", "start"):
12-
pass
11+
def test_base():
12+
with loader.load("specs/base.yml", "start") as output:
13+
assert_output(output, GitAutograderStatus.SUCCESSFUL)
14+
15+
16+
def test_extra_unstaged():
17+
with loader.load("specs/extra_unstaged.yml", "start") as output:
18+
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [EXTRA_FILES_UNSTAGED])
19+
20+
21+
def test_missing_unstaged():
22+
with loader.load("specs/missing_unstaged.yml", "start") as output:
23+
assert_output(
24+
output, GitAutograderStatus.UNSUCCESSFUL, [MISSING_FILES_UNSTAGED]
25+
)
26+
27+
28+
def test_mixed_unstaged():
29+
with loader.load("specs/mixed_unstaged.yml", "start") as output:
30+
assert_output(
31+
output,
32+
GitAutograderStatus.UNSUCCESSFUL,
33+
[EXTRA_FILES_UNSTAGED, MISSING_FILES_UNSTAGED],
34+
)

0 commit comments

Comments
 (0)