@@ -19,7 +19,7 @@ package testutil
19
19
//
20
20
// var body RequestBody
21
21
// var response ResponseBody
22
- // t is *testing.T, from a unit test
22
+ // t is TestReporter, use *testing.T from a unit test
23
23
// e is *echo.Echo
24
24
// response := NewRequest().Post("/path").WithJsonBody(body).GoWithHTTPHandler(t, e)
25
25
// err := response.UnmarshalBodyToObject(&response)
@@ -31,9 +31,12 @@ import (
31
31
"net/http"
32
32
"net/http/httptest"
33
33
"strings"
34
- "testing"
35
34
)
36
35
36
+ type TestReporter interface {
37
+ Errorf (format string , args ... any )
38
+ }
39
+
37
40
func NewRequest () * RequestBuilder {
38
41
return & RequestBuilder {
39
42
Headers : make (map [string ]string ),
@@ -138,7 +141,7 @@ func (r *RequestBuilder) WithCookieNameValue(name, value string) *RequestBuilder
138
141
139
142
// GoWithHTTPHandler performs the request, it takes a pointer to a testing context
140
143
// to print messages, and a http handler for request handling.
141
- func (r * RequestBuilder ) GoWithHTTPHandler (t * testing. T , handler http.Handler ) * CompletedRequest {
144
+ func (r * RequestBuilder ) GoWithHTTPHandler (t TestReporter , handler http.Handler ) * CompletedRequest {
142
145
if r .Error != nil {
143
146
// Fail the test if we had an error
144
147
t .Errorf ("error constructing request: %s" , r .Error )
0 commit comments