-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
runner_option_test.go
105 lines (96 loc) · 2.06 KB
/
runner_option_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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package runn
import "testing"
func TestOpenAPI3(t *testing.T) {
c := &httpRunnerConfig{}
opt := OpenAPI3("path/to/openapi3.yml")
if err := opt(c); err != nil {
t.Fatal(err)
}
got := c.OpenAPI3DocLocation
want := "path/to/openapi3.yml"
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
func TestOpenAPI3FromData(t *testing.T) {
c := &httpRunnerConfig{}
opt := OpenAPI3FromData([]byte(validOpenApi3Spec))
if err := opt(c); err != nil {
t.Fatal(err)
}
if c.openAPI3Doc == nil {
t.Error("c.openApi3Doc shoud not be nil")
}
}
func TestSkipValidateRequest(t *testing.T) {
c := &httpRunnerConfig{}
opt := SkipValidateRequest(true)
if err := opt(c); err != nil {
t.Fatal(err)
}
got := c.SkipValidateRequest
want := true
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
func TestSkipValidateResponse(t *testing.T) {
c := &httpRunnerConfig{}
opt := SkipValidateResponse(true)
if err := opt(c); err != nil {
t.Fatal(err)
}
got := c.SkipValidateResponse
want := true
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
func TestMultipartBoundary(t *testing.T) {
c := &httpRunnerConfig{}
want := "123456789012345678901234567890abcdefghijklmnopqrstuvwxyz"
opt := MultipartBoundary(want)
if err := opt(c); err != nil {
t.Fatal(err)
}
got := c.MultipartBoundary
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
func TestHTTPTimeout(t *testing.T) {
c := &httpRunnerConfig{}
want := "60s"
opt := HTTPTimeout(want)
if err := opt(c); err != nil {
t.Fatal(err)
}
got := c.Timeout
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
func TestUseCookie(t *testing.T) {
c := &httpRunnerConfig{}
want := true
opt := UseCookie(want)
if err := opt(c); err != nil {
t.Fatal(err)
}
got := *c.UseCookie
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
func TestHTTPTrace(t *testing.T) {
c := &httpRunnerConfig{}
want := true
opt := HTTPTrace(want)
if err := opt(c); err != nil {
t.Fatal(err)
}
got := *c.Trace.Enable
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}