(t *testing.T)
| 271 | } |
| 272 | |
| 273 | func TestRequestLogger_LogValuesFuncError(t *testing.T) { |
| 274 | e := echo.New() |
| 275 | |
| 276 | var expect RequestLoggerValues |
| 277 | e.Use(RequestLoggerWithConfig(RequestLoggerConfig{ |
| 278 | LogStatus: true, |
| 279 | LogValuesFunc: func(c *echo.Context, values RequestLoggerValues) error { |
| 280 | expect = values |
| 281 | return echo.NewHTTPError(http.StatusNotAcceptable, "LogValuesFuncError") |
| 282 | }, |
| 283 | })) |
| 284 | |
| 285 | e.GET("/test", func(c *echo.Context) error { |
| 286 | return c.String(http.StatusTeapot, "OK") |
| 287 | }) |
| 288 | |
| 289 | req := httptest.NewRequest(http.MethodGet, "/test", nil) |
| 290 | rec := httptest.NewRecorder() |
| 291 | |
| 292 | e.ServeHTTP(rec, req) |
| 293 | |
| 294 | // NOTE: when global error handler received error returned from middleware the status has already |
| 295 | // been written to the client and response has been "committed" therefore global error handler does not do anything |
| 296 | // and error that bubbled up in middleware chain will not be reflected in response code. |
| 297 | assert.Equal(t, http.StatusTeapot, rec.Code) |
| 298 | assert.Equal(t, http.StatusTeapot, expect.Status) |
| 299 | } |
| 300 | |
| 301 | func TestRequestLogger_ID(t *testing.T) { |
| 302 | var testCases = []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…