@@ -19,7 +19,7 @@ package testutil
1919//
2020// var body RequestBody
2121// var response ResponseBody
22- // t is *testing.T, from a unit test
22+ // t is TestReporter, use *testing.T from a unit test
2323// e is *echo.Echo
2424// response := NewRequest().Post("/path").WithJsonBody(body).GoWithHTTPHandler(t, e)
2525// err := response.UnmarshalBodyToObject(&response)
@@ -31,9 +31,12 @@ import (
3131 "net/http"
3232 "net/http/httptest"
3333 "strings"
34- "testing"
3534)
3635
36+ type TestReporter interface {
37+ Errorf (format string , args ... any )
38+ }
39+
3740func NewRequest () * RequestBuilder {
3841 return & RequestBuilder {
3942 Headers : make (map [string ]string ),
@@ -138,7 +141,7 @@ func (r *RequestBuilder) WithCookieNameValue(name, value string) *RequestBuilder
138141
139142// GoWithHTTPHandler performs the request, it takes a pointer to a testing context
140143// 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 {
142145 if r .Error != nil {
143146 // Fail the test if we had an error
144147 t .Errorf ("error constructing request: %s" , r .Error )
0 commit comments