forked from davecheney/httpstat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
38 lines (31 loc) · 939 Bytes
/
main_test.go
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
package main
import "testing"
func TestParseURL(t *testing.T) {
tests := []struct {
in string
want string
}{
{"https://golang.org", "https://golang.org"},
{"https://golang.org:443/test", "https://golang.org:443/test"},
{"localhost:8080/test", "https://localhost:8080/test"},
{"localhost:80/test", "http://localhost:80/test"},
{"//localhost:8080/test", "https://localhost:8080/test"},
{"//localhost:80/test", "http://localhost:80/test"},
}
for _, test := range tests {
u := parseURL(test.in)
if u.String() != test.want {
t.Errorf("Given: %s\nwant: %s\ngot: %s", test.in, test.want, u.String())
}
}
}
func TestReadClientCert(t *testing.T) {
_, err := readClientCert("./test/singlecert.pem")
if err != nil {
t.Errorf("unable to read single cert and key: %v", err)
}
_, err = readClientCert("./test/multicert.pem")
if err != nil {
t.Errorf("unable to read multiple certs and key: %v", err)
}
}