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

Function TestNoMethodWithGlobalHandlers

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

Source from the content-addressed store, hash-verified

571}
572
573func TestNoMethodWithGlobalHandlers(t *testing.T) {
574 var middleware0 HandlerFunc = func(c *Context) {}
575 var middleware1 HandlerFunc = func(c *Context) {}
576 var middleware2 HandlerFunc = func(c *Context) {}
577
578 router := New()
579 router.Use(middleware2)
580
581 router.NoMethod(middleware0)
582 assert.Len(t, router.allNoMethod, 2)
583 assert.Len(t, router.Handlers, 1)
584 assert.Len(t, router.noMethod, 1)
585
586 compareFunc(t, router.Handlers[0], middleware2)
587 compareFunc(t, router.noMethod[0], middleware0)
588 compareFunc(t, router.allNoMethod[0], middleware2)
589 compareFunc(t, router.allNoMethod[1], middleware0)
590
591 router.Use(middleware1)
592 assert.Len(t, router.allNoMethod, 3)
593 assert.Len(t, router.Handlers, 2)
594 assert.Len(t, router.noMethod, 1)
595
596 compareFunc(t, router.Handlers[0], middleware2)
597 compareFunc(t, router.Handlers[1], middleware1)
598 compareFunc(t, router.noMethod[0], middleware0)
599 compareFunc(t, router.allNoMethod[0], middleware2)
600 compareFunc(t, router.allNoMethod[1], middleware1)
601 compareFunc(t, router.allNoMethod[2], middleware0)
602}
603
604func compareFunc(t *testing.T, a, b any) {
605 sf1 := reflect.ValueOf(a)

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
compareFuncFunction · 0.85
NoMethodMethod · 0.80
UseMethod · 0.65

Tested by

no test coverage detected