-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_test.go
46 lines (35 loc) · 1.15 KB
/
app_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
package gofetch
import (
"testing"
"time"
)
// TestDefaultNewClient verifies that the configuration expected is used when
// a new client is created.
func TestDefaultNewClient(t *testing.T) {
client := New()
want := false
got := client.Config.Debug
if client.Config.Debug != want {
t.Fatalf("expected Debug to be %v, but it is %v", want, got)
}
expectedTimeout := 500 * time.Millisecond
currentTimeout := client.Config.Timeout
if client.Config.Timeout != expectedTimeout {
t.Fatalf("expected Timeout to be %v, but it is %v", expectedTimeout, currentTimeout)
}
}
// TestUserConfigUsedForNewClient ensures that user provided configs are used
// instead of the defaults.
func TestUserConfigUsedForNewClient(t *testing.T) {
expectedTimeout := 200 * time.Millisecond
client := New(Config{Timeout: expectedTimeout, Debug: true})
want := true
got := client.Config.Debug
if client.Config.Debug != want {
t.Fatalf("expected Debug to be %v, but it is %v", want, got)
}
currentTimeout := client.Config.Timeout
if client.Config.Timeout != expectedTimeout {
t.Fatalf("expected Timeout to be %v, but it is %v", expectedTimeout, currentTimeout)
}
}