(t *testing.T)
| 541 | } |
| 542 | |
| 543 | func Test_App_CustomConstraint(t *testing.T) { |
| 544 | t.Parallel() |
| 545 | app := New() |
| 546 | app.RegisterCustomConstraint(&customConstraint{}) |
| 547 | |
| 548 | app.Get("/test/:param<test(test)>", func(c Ctx) error { |
| 549 | return c.SendString("test") |
| 550 | }) |
| 551 | |
| 552 | app.Get("/test2/:param<test>", func(c Ctx) error { |
| 553 | return c.SendString("test") |
| 554 | }) |
| 555 | |
| 556 | app.Get("/test3/:param<test()>", func(c Ctx) error { |
| 557 | return c.SendString("test") |
| 558 | }) |
| 559 | |
| 560 | resp, err := app.Test(httptest.NewRequest(MethodGet, "/test/test", http.NoBody)) |
| 561 | require.NoError(t, err, "app.Test(req)") |
| 562 | require.Equal(t, 200, resp.StatusCode, "Status code") |
| 563 | |
| 564 | resp, err = app.Test(httptest.NewRequest(MethodGet, "/test/test2", http.NoBody)) |
| 565 | require.NoError(t, err, "app.Test(req)") |
| 566 | require.Equal(t, 404, resp.StatusCode, "Status code") |
| 567 | |
| 568 | resp, err = app.Test(httptest.NewRequest(MethodGet, "/test2/c", http.NoBody)) |
| 569 | require.NoError(t, err, "app.Test(req)") |
| 570 | require.Equal(t, 200, resp.StatusCode, "Status code") |
| 571 | |
| 572 | resp, err = app.Test(httptest.NewRequest(MethodGet, "/test2/cc", http.NoBody)) |
| 573 | require.NoError(t, err, "app.Test(req)") |
| 574 | require.Equal(t, 404, resp.StatusCode, "Status code") |
| 575 | |
| 576 | resp, err = app.Test(httptest.NewRequest(MethodGet, "/test3/cc", http.NoBody)) |
| 577 | require.NoError(t, err, "app.Test(req)") |
| 578 | require.Equal(t, 404, resp.StatusCode, "Status code") |
| 579 | } |
| 580 | |
| 581 | func Test_App_ErrorHandler_Custom(t *testing.T) { |
| 582 | t.Parallel() |
nothing calls this directly
no test coverage detected