-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathcurl_test.go
More file actions
93 lines (91 loc) · 2.25 KB
/
curl_test.go
File metadata and controls
93 lines (91 loc) · 2.25 KB
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
package request
import (
"crypto/tls"
"net/http"
"testing"
"time"
)
func TestClient_PrintCURL(t *testing.T) {
type fields struct {
URL string
Method string
Header map[string]string
SortedHeader [][2]string
Query map[string]string
JSON interface{}
XML interface{}
YAML interface{}
String string
URLEncodedForm interface{}
MultipartForm MultipartForm
BasicAuth BasicAuth
CustomerAuth string
Bearer string
Timeout time.Duration
TLSTimeout time.Duration
DialTimeout time.Duration
ProxyURL string
ProxyServers map[string]string
Cookies []*http.Cookie
CookiesMap map[string]string
TLSConfig *tls.Config
Transport *http.Transport
}
tests := []struct {
name string
fields fields
wantErr bool
}{
{
name: "print curl",
fields: fields{
URL: "https://www.google.com",
Method: "POST",
Header: map[string]string{
"h1": "hv1",
},
Query: map[string]string{
"q1": "qv1",
},
JSON: `{"hello":"world"}`,
MultipartForm: MultipartForm{},
BasicAuth: BasicAuth{
Username: "admin",
Password: "admin123",
},
CookiesMap: map[string]string{
"c1": "cv1",
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Client{
URL: tt.fields.URL,
Method: tt.fields.Method,
Header: tt.fields.Header,
SortedHeader: tt.fields.SortedHeader,
Query: tt.fields.Query,
JSON: tt.fields.JSON,
XML: tt.fields.XML,
YAML: tt.fields.YAML,
String: tt.fields.String,
URLEncodedForm: tt.fields.URLEncodedForm,
MultipartForm: tt.fields.MultipartForm,
BasicAuth: tt.fields.BasicAuth,
CustomerAuth: tt.fields.CustomerAuth,
Bearer: tt.fields.Bearer,
Timeout: tt.fields.Timeout,
ProxyURL: tt.fields.ProxyURL,
ProxyServers: tt.fields.ProxyServers,
Cookies: tt.fields.Cookies,
CookiesMap: tt.fields.CookiesMap,
TLSConfig: tt.fields.TLSConfig,
Transport: tt.fields.Transport,
}
c.PrintCURL()
})
}
}