Skip to content

Commit 8aca928

Browse files
committed
Add test for empty required rule configuration fields
The tool output and rules list assume that the text in the required rule configuration fields is present. In cases where it is left empty, this assumption might result in strange or misformatted output. At the moment they are all populated, so that assumption is fine. In the event the test catches an empty field, it can either be fixed or the code changed to not rely on that field being populated.
1 parent d126e70 commit 8aca928

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: internal/rule/ruleconfiguration/ruleconfiguration_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,13 @@ func TestDuplicateRuleID(t *testing.T) {
9595
require.Equalf(t, ruleIndex+1, len(ruleIDMap), "ID %s of rule #%v is a duplicate", ruleConfiguration.ID, ruleIndex)
9696
}
9797
}
98+
99+
func TestRequiredConfigField(t *testing.T) {
100+
for _, ruleConfiguration := range ruleconfiguration.Configurations() {
101+
assert.NotEmptyf(t, ruleConfiguration.Category, "No category defined for rule %s", ruleConfiguration.ID)
102+
assert.NotEmptyf(t, ruleConfiguration.Subcategory, "No subcategory defined for rule %s", ruleConfiguration.ID)
103+
assert.NotEmptyf(t, ruleConfiguration.Brief, "No brief defined for rule %s", ruleConfiguration.ID)
104+
assert.NotEmptyf(t, ruleConfiguration.Description, "No description defined for rule %s", ruleConfiguration.ID)
105+
assert.NotEmptyf(t, ruleConfiguration.MessageTemplate, "No message template defined for rule %s", ruleConfiguration.ID)
106+
}
107+
}

0 commit comments

Comments
 (0)