test(aa-log): add some missing unit tests.

This commit is contained in:
Alexandre Pujol 2023-09-30 15:36:01 +01:00
parent cd80a7d919
commit 0068c1b9a3
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
3 changed files with 91 additions and 4 deletions

View file

@ -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)
}
})
}
}