-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtrack-using-labels_test.rego
74 lines (62 loc) · 1.62 KB
/
track-using-labels_test.rego
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
66
67
68
69
70
71
72
73
74
package spacelift
# Mocked Data for Tests
mock_push_affected := {"affected_files": ["tracked/file.txt", "untracked/file.txt"]}
mock_push_not_affected := {"affected_files": ["not_affected/file.txt"]}
mock_stack_labels_with_trackings := {"labels": ["trackeddirectories:tracked", "trackedextensions:.txt"]}
# Tests
# Test: track rule with different branches
test_track_different_branches {
not track with input as {
"push": {"branch": "main"},
"stack": {"branch": "develop"},
}
}
# Test: propose rule with non-empty branch
test_propose_non_empty_branch {
propose with input as {
"push": {"branch": "main"},
"stack": {},
}
}
# Test: propose rule with empty branch
test_propose_empty_branch {
not propose with input as {
"push": {"branch": ""},
"stack": {},
}
}
# Test: affected by directory path
test_affected_directory {
affected with input as {
"push": mock_push_affected,
"stack": mock_stack_labels_with_trackings,
}
}
# Test: affected by file extension
test_affected_extension {
affected with input as {
"push": mock_push_affected,
"stack": mock_stack_labels_with_trackings,
}
}
# Test: not track by directory path
test_not_affected_directory {
not track with input as {
"push": mock_push_not_affected,
"stack": mock_stack_labels_with_trackings,
}
}
# Test: not track by file extension
test_not_affected_extension {
not track with input as {
"push": mock_push_not_affected,
"stack": mock_stack_labels_with_trackings,
}
}
# Test: track rule with not affected files
test_ignore_not_affected {
not track with input as {
"push": mock_push_not_affected,
"stack": mock_stack_labels_with_trackings,
}
}