Skip to content

Commit a043122

Browse files
committed
chore: change resp to res and change contributor name
Refs: #1
1 parent 596295f commit a043122

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2023 Flávio Gonçalves Garcia
189+
Copyright 2023 Flavio Garcia
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

service.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ type NonceService interface {
1010
Provided(http.ResponseWriter, *http.Request) (bool, error)
1111
}
1212

13-
func Nonced(resp http.ResponseWriter, req *http.Request,
13+
func Nonced(res http.ResponseWriter, req *http.Request,
1414
service NonceService) (err error) {
15-
ok, err := service.Provided(resp, req)
15+
ok, err := service.Provided(res, req)
1616
if err != nil {
1717
return err
1818
}
1919
if !ok {
20-
err = service.Block(resp, req)
20+
err = service.Block(res, req)
2121
if err != nil {
2222
return err
2323
}
@@ -28,7 +28,7 @@ func Nonced(resp http.ResponseWriter, req *http.Request,
2828
return err
2929
}
3030

31-
ok, err = service.Consume(resp, req, nonce)
31+
ok, err = service.Consume(res, req, nonce)
3232
if err != nil {
3333
return err
3434
}

testrunner/testrunner.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,17 @@ func (r *HttpTestRunner) reset() {
194194
}
195195

196196
// 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) {
198198
defer r.reset()
199199
switch r.method {
200200
case http.MethodDelete, http.MethodGet, http.MethodHead, http.MethodPost,
201201
http.MethodPut:
202-
resp, err = r.runMethod()
202+
res, err = r.runMethod()
203203
default:
204-
resp, err = nil, errors.New(
204+
res, err = nil, errors.New(
205205
fmt.Sprintf("unsupported method: %s", r.method))
206206
}
207-
return resp, err
207+
return res, err
208208
}
209209

210210
// resetMethod change to the previous method if it is the case
@@ -216,67 +216,67 @@ func (r *HttpTestRunner) resetMethod(previous string) {
216216

217217
// Delete set method to http.Delete, call HttpTestRunner.Run, and reset method
218218
// 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) {
220220
previousMethod := r.method
221221
r.method = http.MethodDelete
222222
defer r.resetMethod(previousMethod)
223223
r.method = http.MethodDelete
224-
resp, err = r.Run()
225-
return resp, err
224+
res, err = r.Run()
225+
return res, err
226226
}
227227

228228
// Get set method to http.Get, call HttpTestRunner.Run, and reset method to the
229229
// 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) {
231231
previousMethod := r.method
232232
r.method = http.MethodGet
233233
defer r.resetMethod(previousMethod)
234-
resp, err = r.Run()
235-
return resp, err
234+
res, err = r.Run()
235+
return res, err
236236
}
237237

238238
// Head set method to http.Head, call HttpTestRunner.Run, and reset method to
239239
// 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) {
241241
previousMethod := r.method
242242
r.method = http.MethodHead
243243
defer r.resetMethod(previousMethod)
244-
resp, err = r.Run()
245-
return resp, err
244+
res, err = r.Run()
245+
return res, err
246246
}
247247

248248
// Post set method to http.Post, call HttpTestRunner.Run, and reset method to
249249
// 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) {
251251
previousMethod := r.method
252252
r.method = http.MethodPost
253253
defer r.resetMethod(previousMethod)
254-
resp, err = r.Run()
255-
return resp, err
254+
res, err = r.Run()
255+
return res, err
256256
}
257257

258258
// Put set method to http.Put, call HttpTestRunner.Run, and reset method to
259259
// 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) {
261261
previousMethod := r.method
262262
r.method = http.MethodPut
263263
defer r.resetMethod(previousMethod)
264-
resp, err = r.Run()
265-
return resp, err
264+
res, err = r.Run()
265+
return res, err
266266
}
267267

268268
// 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)
271271
if err != nil {
272272
t.Error(err)
273273
}
274274
return string(body)
275275
}
276276

277277
// 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)
280280
if err != nil {
281281
t.Error(err)
282282
}

0 commit comments

Comments
 (0)