@@ -62,7 +62,7 @@ func TestDoSuccessful(t *testing.T) {
62
62
ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
63
63
body , _ := ioutil .ReadAll (r .Body )
64
64
assert .Equal (t , `{"requestValue":"someValueIn"}` + "\n " , string (body ))
65
- assert .Equal (t , r .Method , "POST" )
65
+ assert .Equal (t , r .Method , http . MethodPost )
66
66
w .WriteHeader (http .StatusCreated )
67
67
_ , err := w .Write ([]byte (`{"responseValue":"someValueOut"}` ))
68
68
assert .NoError (t , err )
@@ -71,7 +71,7 @@ func TestDoSuccessful(t *testing.T) {
71
71
72
72
params := Params {
73
73
URL : ts .URL ,
74
- Method : "POST" ,
74
+ Method : http . MethodPost ,
75
75
Body : Input {RequestValue : "someValueIn" },
76
76
ExpectedResponseCode : http .StatusCreated ,
77
77
}
@@ -91,7 +91,7 @@ func TestDoSuccessful(t *testing.T) {
91
91
92
92
params := Params {
93
93
URL : ts .URL + "?beenhere=before" ,
94
- Method : "POST" ,
94
+ Method : http . MethodPost ,
95
95
Query : map [string ]string {
96
96
"testKey" : "testValue" ,
97
97
"öä" : "%&/" ,
@@ -104,15 +104,15 @@ func TestDoSuccessful(t *testing.T) {
104
104
105
105
t .Run ("no request body" , func (t * testing.T ) {
106
106
ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
107
- assert .Equal (t , r .Method , "POST" )
107
+ assert .Equal (t , r .Method , http . MethodPost )
108
108
_ , err := w .Write ([]byte (`{"responseValue":"someValueOut"}` ))
109
109
assert .NoError (t , err )
110
110
}))
111
111
defer ts .Close ()
112
112
113
113
params := Params {
114
114
URL : ts .URL ,
115
- Method : "POST" ,
115
+ Method : http . MethodPost ,
116
116
}
117
117
118
118
result := & Output {}
@@ -123,14 +123,14 @@ func TestDoSuccessful(t *testing.T) {
123
123
124
124
t .Run ("no response body and no request body" , func (t * testing.T ) {
125
125
ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
126
- assert .Equal (t , r .Method , "GET" )
126
+ assert .Equal (t , r .Method , http . MethodGet )
127
127
w .WriteHeader (http .StatusOK )
128
128
}))
129
129
defer ts .Close ()
130
130
131
131
params := Params {
132
132
URL : ts .URL ,
133
- Method : "GET" ,
133
+ Method : http . MethodGet ,
134
134
Body : nil ,
135
135
}
136
136
@@ -147,7 +147,7 @@ func TestDoSuccessful(t *testing.T) {
147
147
148
148
params := Params {
149
149
URL : ts .URL ,
150
- Method : "GET" ,
150
+ Method : http . MethodGet ,
151
151
Body : nil ,
152
152
Timeout : 1 * time .Millisecond ,
153
153
}
@@ -162,15 +162,15 @@ func TestDoSuccessful(t *testing.T) {
162
162
ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
163
163
body , _ := ioutil .ReadAll (r .Body )
164
164
assert .Equal (t , `{"requestValue":"someValueIn"}` , string (body ))
165
- assert .Equal (t , r .Method , "POST" )
165
+ assert .Equal (t , r .Method , http . MethodPost )
166
166
_ , err := w .Write ([]byte (`{"responseValue":"someValueOut"}` ))
167
167
assert .NoError (t , err )
168
168
}))
169
169
defer ts .Close ()
170
170
171
171
params := Params {
172
172
URL : ts .URL ,
173
- Method : "POST" ,
173
+ Method : http . MethodPost ,
174
174
Body : strings .NewReader (`{"requestValue":"someValueIn"}` ),
175
175
}
176
176
@@ -224,7 +224,7 @@ func TestDoHTTPErrors(t *testing.T) {
224
224
225
225
params := Params {
226
226
URL : ts .URL ,
227
- Method : "GET" ,
227
+ Method : http . MethodGet ,
228
228
}
229
229
230
230
err := Do (params , nil )
@@ -245,7 +245,7 @@ func TestDoHTTPErrors(t *testing.T) {
245
245
246
246
params := Params {
247
247
URL : ts .URL ,
248
- Method : "GET" ,
248
+ Method : http . MethodGet ,
249
249
}
250
250
251
251
err := Do (params , nil )
@@ -320,7 +320,7 @@ func TestDoWithStringResponse(t *testing.T) {
320
320
321
321
func TestGet (t * testing.T ) {
322
322
ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
323
- assert .Equal (t , r .Method , "GET" )
323
+ assert .Equal (t , r .Method , http . MethodGet )
324
324
_ , err := w .Write ([]byte (`{"responseValue":"someValueOut"}` ))
325
325
assert .NoError (t , err )
326
326
}))
@@ -336,7 +336,7 @@ func TestPost(t *testing.T) {
336
336
ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
337
337
body , _ := ioutil .ReadAll (r .Body )
338
338
assert .Equal (t , `{"requestValue":"someValueIn"}` + "\n " , string (body ))
339
- assert .Equal (t , r .Method , "POST" )
339
+ assert .Equal (t , r .Method , http . MethodPost )
340
340
_ , err := w .Write ([]byte (`{"responseValue":"someValueOut"}` ))
341
341
assert .NoError (t , err )
342
342
}))
@@ -361,7 +361,7 @@ func ExampleDo() {
361
361
362
362
params := Params {
363
363
URL : ts .URL ,
364
- Method : "POST" ,
364
+ Method : http . MethodPost ,
365
365
Body : Input {RequestValue : "someValueIn" },
366
366
}
367
367
@@ -386,7 +386,7 @@ func ExampleDoWithStringResponse() {
386
386
387
387
params := Params {
388
388
URL : ts .URL ,
389
- Method : "POST" ,
389
+ Method : http . MethodPost ,
390
390
}
391
391
392
392
result , err := DoWithStringResponse (params )
0 commit comments