๐Ÿ“ฆ go-chi / hostrouter

๐Ÿ“„ hostrouter_test.go ยท 26 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26package hostrouter

import "testing"

func Test_getWildcardHost(t *testing.T) {
	type args struct {
		host string
	}
	tests := []struct {
		name string
		args args
		want string
	}{
		{"no wildcard in 1-part host", args{"com"}, "com"},
		{"wildcard in 2-part", args{"dot.com"}, "*.com"},
		{"wildcard in 3-part", args{"amazing.dot.com"}, "*.dot.com"},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := getWildcardHost(tt.args.host); got != tt.want {
				t.Errorf("getWildcardHost() = %v, want %v", got, tt.want)
			}
		})
	}
}