MCPcopy
hub / github.com/labstack/echo / TestContextTimeoutSkipper

Function TestContextTimeoutSkipper

middleware/context_timeout_test.go:20–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func 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
47func TestContextTimeoutWithTimeout0(t *testing.T) {
48 t.Parallel()

Callers

nothing calls this directly

Calls 5

RequestMethod · 0.95
ContextTimeoutWithConfigFunction · 0.85
sleepWithContextFunction · 0.85
NewContextMethod · 0.80
DurationMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…