-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
61 lines (51 loc) · 1.56 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"net/http"
"testing"
)
func TestRememberBodyLazy(t *testing.T) {
resp := Response{
http: &http.Response{
Header: map[string][]string{"Content-Type": {"application/json"}},
},
body: []byte(`# invalid body so it fails if parsed`),
}
err := rememberBody(&resp, map[string]string{}, &Vars{})
if err != nil {
t.Error(err)
}
}
func TestConcatURL(t *testing.T) {
t.Run("open base and closed path", func(t *testing.T) {
base := "http://example.com"
path := "/api/v1/example"
url, _ := concatURL(base, path)
if url != "http://example.com/api/v1/example" {
t.Error("Incorrect url. Expected: http://example.com/api/v1/example. Actual: " + url)
}
})
t.Run("closed base and closed path", func(t *testing.T) {
base := "http://example.com/api/"
path := "/v1/example"
url, _ := concatURL(base, path)
if url != "http://example.com/api/v1/example" {
t.Error("Incorrect url. Expected: http://example.com/api/v1/example. Actual: " + url)
}
})
t.Run("closed base and open path", func(t *testing.T) {
base := "http://example.com/api/"
path := "v1/example"
url, _ := concatURL(base, path)
if url != "http://example.com/api/v1/example" {
t.Error("Incorrect url. Expected: http://example.com/api/v1/example. Actual: " + url)
}
})
t.Run("open base and open path", func(t *testing.T) {
base := "http://example.com/api"
path := "v1/example"
url, _ := concatURL(base, path)
if url != "http://example.com/api/v1/example" {
t.Error("Incorrect url. Expected: http://example.com/api/v1/example. Actual: " + url)
}
})
}