I build a Go Gin reverse proxy API using this page as a guideline: https://le-gall.bzh/author/sebastien-le-gall/
When I try to run tests, I get an error:
interface conversion: *httptest.ResponseRecorder is not http.CloseNotifier: missing method CloseNotify C:/Program Files/Go/src/runtime/iface.go:91 (0x1ab53b)
My test looks something like this:
func Test(t *testing.T) {
expect(t).
GET("/my/path/"). // make a request to the configured router
Expect(). // expect the response
Status(http.StatusOK) // to return with a 200
}
The setup for my tests looks something like this:
var (
router *gin.Engine
)
func expect(t *testing.T) *httpexpect.Expect {
// Create httpexpect instance
e := httpexpect.WithConfig(httpexpect.Config{
Client: &http.Client{
// ensure requests are made against our app router
Transport: httpexpect.NewBinder(router),
Jar: httpexpect.NewJar(),
},
Reporter: httpexpect.NewAssertReporter(t),
Printers: []httpexpect.Printer{
httpexpect.NewDebugPrinter(t, true),
},
})
return e
}
This setup worked fine before I converted it from a standard API into a reverse proxy. I'm not sure what to change to fix this error.