mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 15:43:21 +00:00
Mark helper functions
This commit is contained in:
parent
ec0766cddd
commit
7fe16b69b2
1 changed files with 3 additions and 0 deletions
|
@ -66,6 +66,7 @@ func newRequest(t testing.TB, method, path string, body io.Reader) *http.Request
|
||||||
// wantCode returns a function which checks that the response has the correct HTTP status code.
|
// wantCode returns a function which checks that the response has the correct HTTP status code.
|
||||||
func wantCode(code int) wantFunc {
|
func wantCode(code int) wantFunc {
|
||||||
return func(t testing.TB, res *httptest.ResponseRecorder) {
|
return func(t testing.TB, res *httptest.ResponseRecorder) {
|
||||||
|
t.Helper()
|
||||||
if res.Code != code {
|
if res.Code != code {
|
||||||
t.Errorf("wrong response code, want %v, got %v", code, res.Code)
|
t.Errorf("wrong response code, want %v, got %v", code, res.Code)
|
||||||
}
|
}
|
||||||
|
@ -75,6 +76,7 @@ func wantCode(code int) wantFunc {
|
||||||
// wantBody returns a function which checks that the response has the data in the body.
|
// wantBody returns a function which checks that the response has the data in the body.
|
||||||
func wantBody(body string) wantFunc {
|
func wantBody(body string) wantFunc {
|
||||||
return func(t testing.TB, res *httptest.ResponseRecorder) {
|
return func(t testing.TB, res *httptest.ResponseRecorder) {
|
||||||
|
t.Helper()
|
||||||
if res.Body == nil {
|
if res.Body == nil {
|
||||||
t.Errorf("body is nil, want %q", body)
|
t.Errorf("body is nil, want %q", body)
|
||||||
return
|
return
|
||||||
|
@ -88,6 +90,7 @@ func wantBody(body string) wantFunc {
|
||||||
|
|
||||||
// checkRequest uses f to process the request and runs the checker functions on the result.
|
// checkRequest uses f to process the request and runs the checker functions on the result.
|
||||||
func checkRequest(t testing.TB, f http.HandlerFunc, req *http.Request, want []wantFunc) {
|
func checkRequest(t testing.TB, f http.HandlerFunc, req *http.Request, want []wantFunc) {
|
||||||
|
t.Helper()
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
f(rr, req)
|
f(rr, req)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue