build: refractor internal tools.
This commit is contained in:
parent
df21886965
commit
b0d52d68f4
3 changed files with 29 additions and 5 deletions
|
|
@ -61,7 +61,7 @@ func TestToRegexRepl(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
in []string
|
||||
want []RegexRepl
|
||||
want RegexReplList
|
||||
}{
|
||||
{
|
||||
name: "",
|
||||
|
|
@ -83,3 +83,28 @@ func TestToRegexRepl(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegexReplList_Replace(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
rr RegexReplList
|
||||
str string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "default",
|
||||
rr: []RegexRepl{
|
||||
{Regex: regexp.MustCompile(`^/foo`), Repl: "/bar"},
|
||||
},
|
||||
str: "/foo",
|
||||
want: "/bar",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.rr.Replace(tt.str); got != tt.want {
|
||||
t.Errorf("RegexReplList.Replace() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue