@@ -194,17 +194,17 @@ func (r *HttpTestRunner) reset() {
194
194
}
195
195
196
196
// Run the http method if it is allowed
197
- func (r * HttpTestRunner ) Run () (resp * http.Response , err error ) {
197
+ func (r * HttpTestRunner ) Run () (res * http.Response , err error ) {
198
198
defer r .reset ()
199
199
switch r .method {
200
200
case http .MethodDelete , http .MethodGet , http .MethodHead , http .MethodPost ,
201
201
http .MethodPut :
202
- resp , err = r .runMethod ()
202
+ res , err = r .runMethod ()
203
203
default :
204
- resp , err = nil , errors .New (
204
+ res , err = nil , errors .New (
205
205
fmt .Sprintf ("unsupported method: %s" , r .method ))
206
206
}
207
- return resp , err
207
+ return res , err
208
208
}
209
209
210
210
// resetMethod change to the previous method if it is the case
@@ -216,67 +216,67 @@ func (r *HttpTestRunner) resetMethod(previous string) {
216
216
217
217
// Delete set method to http.Delete, call HttpTestRunner.Run, and reset method
218
218
// to the previous if it is the case.
219
- func (r * HttpTestRunner ) Delete () (resp * http.Response , err error ) {
219
+ func (r * HttpTestRunner ) Delete () (res * http.Response , err error ) {
220
220
previousMethod := r .method
221
221
r .method = http .MethodDelete
222
222
defer r .resetMethod (previousMethod )
223
223
r .method = http .MethodDelete
224
- resp , err = r .Run ()
225
- return resp , err
224
+ res , err = r .Run ()
225
+ return res , err
226
226
}
227
227
228
228
// Get set method to http.Get, call HttpTestRunner.Run, and reset method to the
229
229
// previous if it is the case.
230
- func (r * HttpTestRunner ) Get () (resp * http.Response , err error ) {
230
+ func (r * HttpTestRunner ) Get () (res * http.Response , err error ) {
231
231
previousMethod := r .method
232
232
r .method = http .MethodGet
233
233
defer r .resetMethod (previousMethod )
234
- resp , err = r .Run ()
235
- return resp , err
234
+ res , err = r .Run ()
235
+ return res , err
236
236
}
237
237
238
238
// Head set method to http.Head, call HttpTestRunner.Run, and reset method to
239
239
// the previous if it is the case.
240
- func (r * HttpTestRunner ) Head () (resp * http.Response , err error ) {
240
+ func (r * HttpTestRunner ) Head () (res * http.Response , err error ) {
241
241
previousMethod := r .method
242
242
r .method = http .MethodHead
243
243
defer r .resetMethod (previousMethod )
244
- resp , err = r .Run ()
245
- return resp , err
244
+ res , err = r .Run ()
245
+ return res , err
246
246
}
247
247
248
248
// Post set method to http.Post, call HttpTestRunner.Run, and reset method to
249
249
// the previous if it is the case.
250
- func (r * HttpTestRunner ) Post () (resp * http.Response , err error ) {
250
+ func (r * HttpTestRunner ) Post () (res * http.Response , err error ) {
251
251
previousMethod := r .method
252
252
r .method = http .MethodPost
253
253
defer r .resetMethod (previousMethod )
254
- resp , err = r .Run ()
255
- return resp , err
254
+ res , err = r .Run ()
255
+ return res , err
256
256
}
257
257
258
258
// Put set method to http.Put, call HttpTestRunner.Run, and reset method to
259
259
// the previous if it is the case.
260
- func (r * HttpTestRunner ) Put () (resp * http.Response , err error ) {
260
+ func (r * HttpTestRunner ) Put () (res * http.Response , err error ) {
261
261
previousMethod := r .method
262
262
r .method = http .MethodPut
263
263
defer r .resetMethod (previousMethod )
264
- resp , err = r .Run ()
265
- return resp , err
264
+ res , err = r .Run ()
265
+ return res , err
266
266
}
267
267
268
268
// BodyAsString returns the body of a request as string
269
- func BodyAsString (t * testing.T , resp * http.Response ) string {
270
- body , err := io .ReadAll (resp .Body )
269
+ func BodyAsString (t * testing.T , res * http.Response ) string {
270
+ body , err := io .ReadAll (res .Body )
271
271
if err != nil {
272
272
t .Error (err )
273
273
}
274
274
return string (body )
275
275
}
276
276
277
277
// BodyAsJson unmarshal the body of a request to json
278
- func BodyAsJson (t * testing.T , resp * http.Response , jsonBody any ) {
279
- b , err := io .ReadAll (resp .Body )
278
+ func BodyAsJson (t * testing.T , res * http.Response , jsonBody any ) {
279
+ b , err := io .ReadAll (res .Body )
280
280
if err != nil {
281
281
t .Error (err )
282
282
}
0 commit comments