Skip to content

Commit

Permalink
feat: add fix gin-gonic#2843 test example
Browse files Browse the repository at this point in the history
  • Loading branch information
citizen233 committed Aug 29, 2021
1 parent fc62633 commit d58ba30
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions routes_test.go
Expand Up @@ -621,3 +621,24 @@ func TestRouteContextHoldsFullPath(t *testing.T) {
w := performRequest(router, http.MethodGet, "/not-found")
assert.Equal(t, http.StatusNotFound, w.Code)
}

// Reproduction test for the bug of issue #2843
func TestRouteTrailingSlashRoute(t *testing.T) {
router := New()

router.NoRoute(func(c *Context) {
if c.Request.RequestURI == "/login" {
c.String(200, "login")
}
})

router.GET("/logout", func(c *Context) {
c.String(200, "logout")
})

w := performRequest(router, http.MethodGet, "/login")
assert.Equal(t, "login", w.Body.String())

w = performRequest(router, http.MethodGet, "/logout")
assert.Equal(t, "logout", w.Body.String())
}

0 comments on commit d58ba30

Please sign in to comment.