(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestContextTimeoutSkipper(t *testing.T) { |
| 21 | t.Parallel() |
| 22 | m := ContextTimeoutWithConfig(ContextTimeoutConfig{ |
| 23 | Skipper: func(context *echo.Context) bool { |
| 24 | return true |
| 25 | }, |
| 26 | Timeout: 10 * time.Millisecond, |
| 27 | }) |
| 28 | |
| 29 | req := httptest.NewRequest(http.MethodGet, "/", nil) |
| 30 | rec := httptest.NewRecorder() |
| 31 | |
| 32 | e := echo.New() |
| 33 | c := e.NewContext(req, rec) |
| 34 | |
| 35 | err := m(func(c *echo.Context) error { |
| 36 | if err := sleepWithContext(c.Request().Context(), time.Duration(20*time.Millisecond)); err != nil { |
| 37 | return err |
| 38 | } |
| 39 | |
| 40 | return errors.New("response from handler") |
| 41 | })(c) |
| 42 | |
| 43 | // if not skipped we would have not returned error due context timeout logic |
| 44 | assert.EqualError(t, err, "response from handler") |
| 45 | } |
| 46 | |
| 47 | func TestContextTimeoutWithTimeout0(t *testing.T) { |
| 48 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…