Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow rules for be of any form that starts with warn or deny
- Loading branch information
Brendan Ryan
committed
Jul 18, 2019
1 parent
8f499a1
commit be031f8
Showing
4 changed files
with
103 additions
and
6 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
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,53 @@ | ||
package test | ||
|
||
import "testing" | ||
|
||
func TestWarnQuerry(t *testing.T) { | ||
|
||
tests := []struct{ | ||
in string | ||
exp bool | ||
}{ | ||
{"", false}, | ||
{"warn", true}, | ||
{"warnXYZ", false}, | ||
{"warn_", false}, | ||
{"warn_x", true}, | ||
{"warn_x_y_z", true}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.in, func(t *testing.T) { | ||
res := warnQ.MatchString(tt.in) | ||
|
||
if tt.exp != res { | ||
t.Fatalf("%s recognized as `warn` query - expected: %v actual: %v", tt.in, tt.exp, res) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestFailQuery(t *testing.T) { | ||
|
||
tests := []struct{ | ||
in string | ||
exp bool | ||
}{ | ||
{"", false}, | ||
{"deny", true}, | ||
{"denyXYZ", false}, | ||
{"deny_", false}, | ||
{"deny_x", true}, | ||
{"deny_x_y_z", true}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.in, func(t *testing.T) { | ||
res := denyQ.MatchString(tt.in) | ||
|
||
if tt.exp != res { | ||
t.Fatalf("%s recognized as `fail` query - expected: %v actual: %v", tt.in, tt.exp, res) | ||
} | ||
}) | ||
} | ||
} |