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

Function TestRebuild404Handlers

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

Source from the content-addressed store, hash-verified

545}
546
547func TestRebuild404Handlers(t *testing.T) {
548 var middleware0 HandlerFunc = func(c *Context) {}
549 var middleware1 HandlerFunc = func(c *Context) {}
550
551 router := New()
552
553 // Initially, allNoRoute should be nil
554 assert.Nil(t, router.allNoRoute)
555
556 // Set NoRoute handlers
557 router.NoRoute(middleware0)
558 assert.Len(t, router.allNoRoute, 1)
559 assert.Len(t, router.noRoute, 1)
560 compareFunc(t, router.allNoRoute[0], middleware0)
561
562 // Add Use middleware should trigger rebuild404Handlers
563 router.Use(middleware1)
564 assert.Len(t, router.allNoRoute, 2)
565 assert.Len(t, router.Handlers, 1)
566 assert.Len(t, router.noRoute, 1)
567
568 // Global middleware should come first
569 compareFunc(t, router.allNoRoute[0], middleware1)
570 compareFunc(t, router.allNoRoute[1], middleware0)
571}
572
573func TestNoMethodWithGlobalHandlers(t *testing.T) {
574 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