-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: allow whitespace after comma in ignore validations comments (#89)
* chore: allow whitespace after comma in ignore validations comments * chore: remove empty elements caused by trailing comma * move exclude rules generation into a func and add tests * simplifed generateExcludedRules and updated test case per request * add deduplication of ignored rule names * remove unused field * avoid using continue in a loop * update unit tests to account for deduplication * fix: lint Signed-off-by: Martin Chodur <[email protected]> * fix: white spaces in the `disabled_validation_rules` annotation CSV Signed-off-by: Martin Chodur <[email protected]> * fix: assert import Signed-off-by: Martin Chodur <[email protected]> --------- Signed-off-by: Martin Chodur <[email protected]> Co-authored-by: Martin Chodur <[email protected]>
- Loading branch information
1 parent
e5eaf73
commit 666b9c0
Showing
3 changed files
with
76 additions
and
1 deletion.
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
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
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,62 @@ | ||
package validate | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGenerateExcludedRules(t *testing.T) { | ||
type testCase struct { | ||
input string | ||
expected []string | ||
} | ||
testCases := []testCase{ | ||
{ | ||
input: "check-test-label,check-testy-label", | ||
expected: []string{"check-test-label", "check-testy-label"}, | ||
}, | ||
{ | ||
input: "check-test-label,check-test-label", | ||
expected: []string{"check-test-label"}, | ||
}, | ||
{ | ||
input: "check-test-label, check-testy-label", | ||
expected: []string{"check-test-label", "check-testy-label"}, | ||
}, | ||
{ | ||
input: "check-test-label, check-testy-label,", | ||
expected: []string{"check-test-label", "check-testy-label"}, | ||
}, | ||
{ | ||
input: "check-test-label ,check-test-label", | ||
expected: []string{"check-test-label"}, | ||
}, | ||
{ | ||
input: "check-test-label,check-test-label, ", | ||
expected: []string{"check-test-label"}, | ||
}, | ||
{ | ||
input: "check-test-label , check testy label , ", | ||
expected: []string{"check testy label", "check-test-label"}, | ||
}, | ||
{ | ||
input: "check-test-label , check-testy-label ", | ||
expected: []string{"check-test-label", "check-testy-label"}, | ||
}, | ||
{ | ||
input: "check-test-label , check-testy-label, , ", | ||
expected: []string{"check-test-label", "check-testy-label"}, | ||
}, | ||
{ | ||
input: " check-test-label , check-testy-label , , ", | ||
expected: []string{"check-test-label", "check-testy-label"}, | ||
}, | ||
} | ||
for i, tc := range testCases { | ||
t.Run(string(rune(i)), func(t *testing.T) { | ||
result := generateExcludedRules(tc.input) | ||
assert.Equal(t, tc.expected, result) | ||
}) | ||
} | ||
} |