forked from micromdm/micromdm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_test.go
More file actions
41 lines (38 loc) · 833 Bytes
/
Copy pathconfig_test.go
File metadata and controls
41 lines (38 loc) · 833 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import "testing"
func TestValidateServerURL(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{
name: "http",
input: "http://localhost:8000",
expected: "http://localhost:8000/",
},
{
name: "https",
input: "https://localhost:8000",
expected: "https://localhost:8000/",
},
{
name: "trailing_slash",
input: "https://localhost:8000/",
expected: "https://localhost:8000/",
},
{
name: "no_prefix",
input: "localhost:8000",
expected: "https://localhost:8000/",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actualURL, _ := validateServerURL(tt.input)
if have, want := actualURL, tt.expected; have != want {
t.Errorf("have %s, want %s", have, want)
}
})
}
}