(t *testing.T)
| 79 | } |
| 80 | |
| 81 | func 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 | |
| 103 | func TestContextTimeoutTestRequestClone(t *testing.T) { |
| 104 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…