-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
47 lines (35 loc) · 832 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
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"reflect"
"testing"
"time"
)
func TestSplitContent(t *testing.T) {
content := []byte("www.youtube.com\nwww.google.com")
got := splitContent(content)
want := []string{"www.youtube.com", "www.google.com"}
if !reflect.DeepEqual(got, want) {
t.Errorf("got %s, want %s", got, want)
}
}
func TestFormatHostConfig(t *testing.T) {
h := []string{"www.youtube.com", "www.google.com"}
got := formatHostsConfig(h)
want := fmt.Sprintf(`
%s www.youtube.com
%s www.google.com
`, IPAddress, IPAddress)
AssertEqual(t, got, want)
}
func TestFormatMinutes(t *testing.T) {
d := time.Duration(60) * time.Minute
got := formatMinutes(d)
want := "60:00"
AssertEqual(t, got, want)
}
func AssertEqual(t *testing.T, got, want string) {
if got != want {
t.Errorf("got %s, want %s", got, want)
}
}