| 1078 | } |
| 1079 | |
| 1080 | func Test_App_All_Method_Test(t *testing.T) { |
| 1081 | t.Parallel() |
| 1082 | |
| 1083 | methods := append(DefaultMethods, "JOHN") //nolint:gocritic // We want a new slice here |
| 1084 | app := New(Config{ |
| 1085 | RequestMethods: methods, |
| 1086 | }) |
| 1087 | |
| 1088 | // Add a new method with All |
| 1089 | app.All("/doe", testEmptyHandler) |
| 1090 | |
| 1091 | resp, err := app.Test(httptest.NewRequest("JOHN", "/doe", http.NoBody)) |
| 1092 | require.NoError(t, err, "app.Test(req)") |
| 1093 | require.Equal(t, StatusOK, resp.StatusCode, "Status code") |
| 1094 | |
| 1095 | // Add a new method |
| 1096 | require.Panics(t, func() { |
| 1097 | app.Add([]string{"JANE"}, "/jane", testEmptyHandler) |
| 1098 | }) |
| 1099 | } |
| 1100 | |
| 1101 | // go test -run Test_App_GETOnly |
| 1102 | func Test_App_GETOnly(t *testing.T) { |