MCPcopy Index your code
hub / github.com/coder/coder / TestNormalizeHost

Function TestNormalizeHost

cli/sessionstore/sessionstore_internal_test.go:11–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestNormalizeHost(t *testing.T) {
12 t.Parallel()
13
14 tests := []struct {
15 name string
16 url *url.URL
17 want string
18 wantErr bool
19 }{
20 {
21 name: "StandardHost",
22 url: &url.URL{Host: "coder.example.com"},
23 want: "coder.example.com",
24 },
25 {
26 name: "HostWithPort",
27 url: &url.URL{Host: "coder.example.com:8080"},
28 want: "coder.example.com:8080",
29 },
30 {
31 name: "UppercaseHost",
32 url: &url.URL{Host: "CODER.EXAMPLE.COM"},
33 want: "coder.example.com",
34 },
35 {
36 name: "HostWithWhitespace",
37 url: &url.URL{Host: " coder.example.com "},
38 want: "coder.example.com",
39 },
40 {
41 name: "NilURL",
42 url: nil,
43 want: "",
44 wantErr: true,
45 },
46 {
47 name: "EmptyHost",
48 url: &url.URL{Host: ""},
49 want: "",
50 wantErr: true,
51 },
52 }
53
54 for _, tt := range tests {
55 t.Run(tt.name, func(t *testing.T) {
56 t.Parallel()
57 got, err := normalizeHost(tt.url)
58 if tt.wantErr {
59 require.Error(t, err)
60 return
61 }
62 require.NoError(t, err)
63 require.Equal(t, tt.want, got)
64 })
65 }
66}
67
68func TestParseCredentialsJSON(t *testing.T) {

Callers

nothing calls this directly

Calls 4

normalizeHostFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected