Skip to content

Commit

Permalink
Add tests for enforce_file ruletype
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslav Dimitrov <[email protected]>
  • Loading branch information
rdimitrov committed Dec 18, 2024
1 parent f562175 commit c247f61
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
48 changes: 48 additions & 0 deletions rule-types/common/enforce_file.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
tests:
- name: "File should be present"
def:
file: README
content: ""
params: {}
expect: "pass"
git:
repo_base: file_present
- name: "File is missing"
def:
file: README
params: {}
expect: "fail"
git:
repo_base: file_missing
- name: "File present and matches content"
def:
file: README
content: "Test content"
params: {}
expect: "pass"
git:
repo_base: file_present
- name: "File present, but has different content"
def:
file: README
content: "Different content"
params: {}
expect: "fail"
git:
repo_base: file_present
- name: "File present, but has more content than expected"
def:
file: README
content: "Test"
params: { }
expect: "fail"
git:
repo_base: file_present
- name: "File present, but has less content than expected"
def:
file: README
content: "Test content with a subset"
params: { }
expect: "fail"
git:
repo_base: file_present
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test content
2 changes: 0 additions & 2 deletions rule-types/common/enforce_file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ def:
description: |
The content to enforce in the file.
For example, the content of the LICENSE file.
Leave "" to only check for the presence of the file.
default: ""
required:
- file
Expand Down

0 comments on commit c247f61

Please sign in to comment.