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

Function TestContextTimeoutSuccessfulRequest

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

Source from the content-addressed store, hash-verified

79}
80
81func TestContextTimeoutSuccessfulRequest(t *testing.T) {
82 t.Parallel()
83 m := ContextTimeoutWithConfig(ContextTimeoutConfig{
84 // Timeout has to be defined or the whole flow for timeout middleware will be skipped
85 Timeout: 10 * time.Millisecond,
86 })
87
88 req := httptest.NewRequest(http.MethodGet, "/", nil)
89 rec := httptest.NewRecorder()
90
91 e := echo.New()
92 c := e.NewContext(req, rec)
93
94 err := m(func(c *echo.Context) error {
95 return c.JSON(http.StatusCreated, map[string]string{"data": "ok"})
96 })(c)
97
98 assert.NoError(t, err)
99 assert.Equal(t, http.StatusCreated, rec.Code)
100 assert.Equal(t, "{\"data\":\"ok\"}\n", rec.Body.String())
101}
102
103func TestContextTimeoutTestRequestClone(t *testing.T) {
104 t.Parallel()

Callers

nothing calls this directly

Calls 4

JSONMethod · 0.95
ContextTimeoutWithConfigFunction · 0.85
NewContextMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…