(t *testing.T)
| 101 | } |
| 102 | |
| 103 | func TestContextTimeoutTestRequestClone(t *testing.T) { |
| 104 | t.Parallel() |
| 105 | req := httptest.NewRequest(http.MethodPost, "/uri?query=value", strings.NewReader(url.Values{"form": {"value"}}.Encode())) |
| 106 | req.AddCookie(&http.Cookie{Name: "cookie", Value: "value"}) |
| 107 | req.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| 108 | rec := httptest.NewRecorder() |
| 109 | |
| 110 | m := ContextTimeoutWithConfig(ContextTimeoutConfig{ |
| 111 | // Timeout has to be defined or the whole flow for timeout middleware will be skipped |
| 112 | Timeout: 1 * time.Second, |
| 113 | }) |
| 114 | |
| 115 | e := echo.New() |
| 116 | c := e.NewContext(req, rec) |
| 117 | |
| 118 | err := m(func(c *echo.Context) error { |
| 119 | // Cookie test |
| 120 | cookie, err := c.Request().Cookie("cookie") |
| 121 | if assert.NoError(t, err) { |
| 122 | assert.EqualValues(t, "cookie", cookie.Name) |
| 123 | assert.EqualValues(t, "value", cookie.Value) |
| 124 | } |
| 125 | |
| 126 | // Form values |
| 127 | if assert.NoError(t, c.Request().ParseForm()) { |
| 128 | assert.EqualValues(t, "value", c.Request().FormValue("form")) |
| 129 | } |
| 130 | |
| 131 | // Query string |
| 132 | assert.EqualValues(t, "value", c.Request().URL.Query()["query"][0]) |
| 133 | return nil |
| 134 | })(c) |
| 135 | |
| 136 | assert.NoError(t, err) |
| 137 | } |
| 138 | |
| 139 | func TestContextTimeoutWithDefaultErrorMessage(t *testing.T) { |
| 140 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…