MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / TestErrorHandlerFunc

Function TestErrorHandlerFunc

internal/test/server/server_test.go:104–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestErrorHandlerFunc(t *testing.T) {
105 m := fakeServer{}
106
107 h := HandlerWithOptions(&m, ChiServerOptions{
108 ErrorHandlerFunc: func(w http.ResponseWriter, r *http.Request, err error) {
109 w.Header().Set("Content-Type", "application/json")
110 var requiredParamError *RequiredParamError
111 assert.True(t, errors.As(err, &requiredParamError))
112 },
113 })
114
115 s := httptest.NewServer(h)
116 defer s.Close()
117
118 req, err := http.DefaultClient.Get(s.URL + "/get-with-args")
119 assert.Nil(t, err)
120 assert.Equal(t, "application/json", req.Header.Get("Content-Type"))
121}
122
123func TestErrorHandlerFuncBackwardsCompatible(t *testing.T) {
124 m := fakeServer{}

Callers

nothing calls this directly

Calls 3

HandlerWithOptionsFunction · 0.70
SetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected