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

Function TestAddRoute

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

Source from the content-addressed store, hash-verified

435}
436
437func TestAddRoute(t *testing.T) {
438 router := New()
439 router.addRoute(http.MethodGet, "/", HandlersChain{func(_ *Context) {}})
440
441 assert.Len(t, router.trees, 1)
442 assert.NotNil(t, router.trees.get(http.MethodGet))
443 assert.Nil(t, router.trees.get(http.MethodPost))
444
445 router.addRoute(http.MethodPost, "/", HandlersChain{func(_ *Context) {}})
446
447 assert.Len(t, router.trees, 2)
448 assert.NotNil(t, router.trees.get(http.MethodGet))
449 assert.NotNil(t, router.trees.get(http.MethodPost))
450
451 router.addRoute(http.MethodPost, "/post", HandlersChain{func(_ *Context) {}})
452 assert.Len(t, router.trees, 2)
453}
454
455func TestAddRouteFails(t *testing.T) {
456 router := New()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
getMethod · 0.80
addRouteMethod · 0.45

Tested by

no test coverage detected