| 1135 | } |
| 1136 | |
| 1137 | func Test_App_Chaining(t *testing.T) { |
| 1138 | t.Parallel() |
| 1139 | n := func(c Ctx) error { |
| 1140 | return c.Next() |
| 1141 | } |
| 1142 | app := New() |
| 1143 | app.Use("/john", n, n, n, n, func(c Ctx) error { |
| 1144 | return c.SendStatus(202) |
| 1145 | }) |
| 1146 | // check handler count for registered HEAD route |
| 1147 | require.Len(t, app.stack[app.methodInt(MethodHead)][0].Handlers, 5, "app.Test(req)") |
| 1148 | |
| 1149 | req := httptest.NewRequest(MethodPost, "/john", http.NoBody) |
| 1150 | |
| 1151 | resp, err := app.Test(req) |
| 1152 | require.NoError(t, err, "app.Test(req)") |
| 1153 | require.Equal(t, 202, resp.StatusCode, "Status code") |
| 1154 | |
| 1155 | app.Get("/test", n, n, n, n, func(c Ctx) error { |
| 1156 | return c.SendStatus(203) |
| 1157 | }) |
| 1158 | |
| 1159 | req = httptest.NewRequest(MethodGet, "/test", http.NoBody) |
| 1160 | |
| 1161 | resp, err = app.Test(req) |
| 1162 | require.NoError(t, err, "app.Test(req)") |
| 1163 | require.Equal(t, 203, resp.StatusCode, "Status code") |
| 1164 | } |
| 1165 | |
| 1166 | func Test_App_Order(t *testing.T) { |
| 1167 | t.Parallel() |