git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/httpx/hostrouter/hostrouter_test.go (about) 1 package hostrouter 2 3 import "testing" 4 5 func Test_getWildcardHost(t *testing.T) { 6 type args struct { 7 host string 8 } 9 tests := []struct { 10 name string 11 args args 12 want string 13 }{ 14 {"no wildcard in 1-part host", args{"com"}, "com"}, 15 {"wildcard in 2-part", args{"dot.com"}, "*.com"}, 16 {"wildcard in 3-part", args{"amazing.dot.com"}, "*.dot.com"}, 17 } 18 for _, tt := range tests { 19 t.Run(tt.name, func(t *testing.T) { 20 if got := getWildcardHost(tt.args.host); got != tt.want { 21 t.Errorf("getWildcardHost() = %v, want %v", got, tt.want) 22 } 23 }) 24 } 25 }