MCPcopy
hub / github.com/gin-gonic/gin / TestNoRouteWithGlobalHandlers

Function TestNoRouteWithGlobalHandlers

gin_test.go:494–523  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

492}
493
494func TestNoRouteWithGlobalHandlers(t *testing.T) {
495 var middleware0 HandlerFunc = func(c *Context) {}
496 var middleware1 HandlerFunc = func(c *Context) {}
497 var middleware2 HandlerFunc = func(c *Context) {}
498
499 router := New()
500 router.Use(middleware2)
501
502 router.NoRoute(middleware0)
503 assert.Len(t, router.allNoRoute, 2)
504 assert.Len(t, router.Handlers, 1)
505 assert.Len(t, router.noRoute, 1)
506
507 compareFunc(t, router.Handlers[0], middleware2)
508 compareFunc(t, router.noRoute[0], middleware0)
509 compareFunc(t, router.allNoRoute[0], middleware2)
510 compareFunc(t, router.allNoRoute[1], middleware0)
511
512 router.Use(middleware1)
513 assert.Len(t, router.allNoRoute, 3)
514 assert.Len(t, router.Handlers, 2)
515 assert.Len(t, router.noRoute, 1)
516
517 compareFunc(t, router.Handlers[0], middleware2)
518 compareFunc(t, router.Handlers[1], middleware1)
519 compareFunc(t, router.noRoute[0], middleware0)
520 compareFunc(t, router.allNoRoute[0], middleware2)
521 compareFunc(t, router.allNoRoute[1], middleware1)
522 compareFunc(t, router.allNoRoute[2], middleware0)
523}
524
525func TestNoMethodWithoutGlobalHandlers(t *testing.T) {
526 var middleware0 HandlerFunc = func(c *Context) {}

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
compareFuncFunction · 0.85
NoRouteMethod · 0.80
UseMethod · 0.65

Tested by

no test coverage detected