test(aa-log): add some missing unit tests.
This commit is contained in:
parent
cd80a7d919
commit
0068c1b9a3
3 changed files with 91 additions and 4 deletions
|
|
@ -6,6 +6,7 @@ package util
|
|||
|
||||
import (
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
@ -55,3 +56,30 @@ func TestRemoveDuplicate(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestToRegexRepl(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
in []string
|
||||
want []RegexRepl
|
||||
}{
|
||||
{
|
||||
name: "",
|
||||
in: []string{
|
||||
"^/foo/bar", "/foo/bar",
|
||||
"^/foo/bar", "/foo/bar",
|
||||
},
|
||||
want: []RegexRepl{
|
||||
{Regex: regexp.MustCompile("^/foo/bar"), Repl: "/foo/bar"},
|
||||
{Regex: regexp.MustCompile("^/foo/bar"), Repl: "/foo/bar"},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := ToRegexRepl(tt.in); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("ToRegexRepl() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue