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

Function TestRouterMethod

routes_test.go:89–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestRouterMethod(t *testing.T) {
90 router := New()
91 router.PUT("/hey2", func(c *Context) {
92 c.String(http.StatusOK, "sup2")
93 })
94
95 router.PUT("/hey", func(c *Context) {
96 c.String(http.StatusOK, "called")
97 })
98
99 router.PUT("/hey3", func(c *Context) {
100 c.String(http.StatusOK, "sup3")
101 })
102
103 w := PerformRequest(router, http.MethodPut, "/hey")
104
105 assert.Equal(t, http.StatusOK, w.Code)
106 assert.Equal(t, "called", w.Body.String())
107}
108
109func TestRouterGroupRouteOK(t *testing.T) {
110 testRouteOK(http.MethodGet, t)

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
PerformRequestFunction · 0.85
PUTMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected