mirror of
https://github.com/vbatts/git-validation.git
synced 2024-12-28 00:16:29 +00:00
Vincent Batts
00823a324b
Fixes: #30 now you can add a regular expression to the rules to be run i.e. `git-validation -run "dco,message_regexp='^JIRA-[0-9]+ [A-Z].*$'"` Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package validate
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSanitizeRules(t *testing.T) {
|
|
set := []struct {
|
|
input string
|
|
output []string
|
|
}{
|
|
{
|
|
input: "apples, oranges , bananas",
|
|
output: []string{"apples", "oranges", "bananas"},
|
|
},
|
|
{
|
|
input: "apples, oranges , bananas, peaches='with cream'",
|
|
output: []string{"apples", "oranges", "bananas", "peaches='with cream'"},
|
|
},
|
|
}
|
|
|
|
for i := range set {
|
|
filt := SanitizeFilters(set[i].input)
|
|
if !StringsSliceEqual(filt, set[i].output) {
|
|
t.Errorf("expected output like %v, but got %v", set[i].output, filt)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSliceHelpers(t *testing.T) {
|
|
set := []struct {
|
|
A, B []string
|
|
Equal bool
|
|
}{
|
|
{
|
|
A: []string{"apples", "bananas", "oranges", "mango"},
|
|
B: []string{"oranges", "bananas", "apples", "mango"},
|
|
Equal: true,
|
|
},
|
|
{
|
|
A: []string{"apples", "bananas", "oranges", "mango"},
|
|
B: []string{"waffles"},
|
|
Equal: false,
|
|
},
|
|
}
|
|
for i := range set {
|
|
got := StringsSliceEqual(set[i].A, set[i].B)
|
|
if got != set[i].Equal {
|
|
t.Errorf("expected %d A and B comparison to be %t, but got %t", i, set[i].Equal, got)
|
|
}
|
|
}
|
|
}
|