go test -v -run=^$ -bench=Benchmark_App_MethodNotAllowed -benchmem -count=4
(b *testing.B)
| 1508 | |
| 1509 | // go test -v -run=^$ -bench=Benchmark_App_MethodNotAllowed -benchmem -count=4 |
| 1510 | func Benchmark_App_MethodNotAllowed(b *testing.B) { |
| 1511 | app := New() |
| 1512 | h := func(c Ctx) error { |
| 1513 | return c.SendString("Hello World!") |
| 1514 | } |
| 1515 | app.All("/this/is/a/", h) |
| 1516 | app.Get("/this/is/a/dummy/route/oke", h) |
| 1517 | appHandler := app.Handler() |
| 1518 | c := &fasthttp.RequestCtx{} |
| 1519 | |
| 1520 | c.Request.Header.SetMethod("DELETE") |
| 1521 | c.URI().SetPath("/this/is/a/dummy/route/oke") |
| 1522 | |
| 1523 | for b.Loop() { |
| 1524 | appHandler(c) |
| 1525 | } |
| 1526 | require.Equal(b, 405, c.Response.StatusCode()) |
| 1527 | require.Equal(b, MethodGet+", "+MethodHead, string(c.Response.Header.Peek("Allow"))) |
| 1528 | require.Equal(b, utils.StatusMessage(StatusMethodNotAllowed), string(c.Response.Body())) |
| 1529 | } |
| 1530 | |
| 1531 | // go test -v ./... -run=^$ -bench=Benchmark_Router_NotFound -benchmem -count=4 |
| 1532 | func Benchmark_Router_NotFound(b *testing.B) { |
nothing calls this directly
no test coverage detected