-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
41 lines (34 loc) · 1 KB
/
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
39
40
41
package main
import "testing"
func TestGetValidUrl(t *testing.T) {
cases := map[string]struct{ addr_string, expected string }{
"full address string": {"http://127.0.0.1:4444", "http://127.0.0.1:4444"},
"no port": {"http://127.0.0.1", "http://127.0.0.1:4444"},
"no proto": {"127.0.0.1:4444", "http://127.0.0.1:4444"},
}
for k, tc := range cases {
actual := getValidUrl(tc.addr_string)
if actual != tc.expected {
t.Errorf(
"%s: URL is '%s', expected '%s'",
k, tc.addr_string, tc.expected,
)
}
}
}
func TestGetValidScreenshotFile(t *testing.T) {
cases := map[string]struct{ name, expected string }{
"no extension": {"screenshot", "screenshot.jpg"},
"jpeg extension": {"screenshot.jpeg", "screenshot.jpeg"},
"jpg extension": {"screenshot.jpg", "screenshot.jpg"},
}
for k, tc := range cases {
actual := getValidScreenshotFile(tc.name)
if actual != tc.expected {
t.Errorf(
"%s: URL is '%s', expected '%s'",
k, tc.name, tc.expected,
)
}
}
}