-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for requiring reasonable commit size policy
- Loading branch information
1 parent
c9b801a
commit 986853d
Showing
1 changed file
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
package spacelift | ||
|
||
# Test case for denying proposed run with too many changes. | ||
test_deny_for_proposed_run_with_too_many_changes { | ||
inp := { | ||
"spacelift": {"run": {"type": "PROPOSED"}}, | ||
"terraform": {"resource_changes": [ | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
]}, | ||
} | ||
count(warn) == 0 with input as inp | ||
deny["More than 50 changes (51)"] with input as inp | ||
} | ||
|
||
# Test case for denying tracked with too many changes. | ||
test_deny_for_tracked_run_with_too_many_changes { | ||
inp := { | ||
"spacelift": {"run": {"type": "TRACKED"}}, | ||
"terraform": {"resource_changes": [ | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
]}, | ||
} | ||
count(deny) == 0 with input as inp | ||
warn["More than 50 changes (51)"] with input as inp | ||
} | ||
|
||
# Test case if no-op changes are included. | ||
test_no_op_changes { | ||
inp := { | ||
"spacelift": {"run": {"type": "TRACKED"}}, | ||
"terraform": {"resource_changes": [ | ||
{"change": {"actions": ["no-op"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
{"change": {"actions": ["delete"]}}, | ||
]}, | ||
} | ||
count(deny) == 0 with input as inp | ||
count(warn) == 0 with input as inp | ||
} | ||
|
||
# Test case tracked run for no warning for reasonable commit. | ||
test_no_warn_for_tracked_run_with_reasonable_commit { | ||
inp := { | ||
"spacelift": {"run": {"type": "TRACKED"}}, | ||
"terraform": {"resource_changes": [{"change": {"actions": ["delete"]}}]}, | ||
} | ||
count(deny) == 0 with input as inp | ||
count(warn) == 0 with input as inp | ||
} | ||
|
||
# Test case tracked run for no denying for reasonable commit. | ||
test_no_deny_for_proposed_run_with_reasonable_commit { | ||
inp := { | ||
"spacelift": {"run": {"type": "PROPOSED"}}, | ||
"terraform": {"resource_changes": [{"change": {"actions": ["delete"]}}]}, | ||
} | ||
count(deny) == 0 with input as inp | ||
count(warn) == 0 with input as inp | ||
} |