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

Function TestLiteralColonWithRun

gin_test.go:990–1007  ·  gin_test.go::TestLiteralColonWithRun

Test the fix for https://github.com/gin-gonic/gin/pull/4415

(t *testing.T)

Source from the content-addressed store, hash-verified

988
989// Test the fix for https://github.com/gin-gonic/gin/pull/4415
990func TestLiteralColonWithRun(t *testing.T) {
991 SetMode(TestMode)
992 router := New()
993
994 router.GET(`/test\:action`, func(c *Context) {
995 c.JSON(http.StatusOK, H{"path": "literal_colon"})
996 })
997
998 router.updateRouteTrees()
999
1000 w := httptest.NewRecorder()
1001
1002 req, _ := http.NewRequest(http.MethodGet, "/test:action", nil)
1003 router.ServeHTTP(w, req)
1004
1005 assert.Equal(t, http.StatusOK, w.Code)
1006 assert.Contains(t, w.Body.String(), "literal_colon")
1007}
1008
1009func TestLiteralColonWithDirectServeHTTP(t *testing.T) {
1010 SetMode(TestMode)

Callers

nothing calls this directly

Calls 7

SetModeFunction · 0.85
NewFunction · 0.85
updateRouteTreesMethod · 0.80
GETMethod · 0.65
StringMethod · 0.65
JSONMethod · 0.45
ServeHTTPMethod · 0.45

Tested by

no test coverage detected