-
Notifications
You must be signed in to change notification settings - Fork 6
/
global_test.go
55 lines (45 loc) · 1.46 KB
/
global_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
48
49
50
51
52
53
54
55
package fetch
import (
"fmt"
"testing"
"time"
)
func TestGlobalSetBaseURL(t *testing.T) {
if BaseURL != "" {
t.Errorf("global BaseURL should be empty string, but got %s", BaseURL)
}
SetBaseURL("https://example.com")
if BaseURL != "https://example.com" {
t.Errorf("global BaseURL should be https://example.com, but got %s", BaseURL)
}
SetBaseURL("")
if BaseURL != "" {
t.Errorf("global BaseURL should be empty string, but got %s", BaseURL)
}
}
func TestGlobalUserAgent(t *testing.T) {
if UserAgent != fmt.Sprintf("GoFetch/%s (github.com/go-zoox/fetch)", Version) {
t.Errorf("global UserAgent should be empty string, but got %s", UserAgent)
}
SetUserAgent("test user agent")
if UserAgent != "test user agent" {
t.Errorf("global UserAgent should be test user agent, but got %s", UserAgent)
}
SetUserAgent(fmt.Sprintf("GoFetch/%s (github.com/go-zoox/fetch)", Version))
if UserAgent != fmt.Sprintf("GoFetch/%s (github.com/go-zoox/fetch)", Version) {
t.Errorf("global UserAgent should be empty string, but got %s", UserAgent)
}
}
func TestGlobalTimeout(t *testing.T) {
if Timeout != 60*time.Second {
t.Errorf("global Timeout should be empty string, but got %s", Timeout)
}
SetTimeout(30 * time.Second)
if Timeout != 30*time.Second {
t.Errorf("global Timeout should be test user agent, but got %s", Timeout)
}
SetTimeout(60 * time.Second)
if Timeout != 60*time.Second {
t.Errorf("global Timeout should be empty string, but got %s", Timeout)
}
}