mirror of
https://github.com/gin-gonic/gin.git
synced 2025-12-13 13:12:17 +08:00
chore: removed unused variable and updated TestUpdateRouteTreesCalledOnce testcase
This commit is contained in:
parent
12600156ae
commit
232172b7e4
@ -93,19 +93,15 @@ func TestUpdateRouteTreesCalledOnce(t *testing.T) {
|
|||||||
SetMode(TestMode)
|
SetMode(TestMode)
|
||||||
router := New()
|
router := New()
|
||||||
|
|
||||||
callCount := 0
|
|
||||||
originalUpdate := router.updateRouteTrees
|
|
||||||
|
|
||||||
router.GET(`/test\:action`, func(c *Context) {
|
router.GET(`/test\:action`, func(c *Context) {
|
||||||
c.JSON(http.StatusOK, H{"call": callCount})
|
c.String(http.StatusOK, "ok")
|
||||||
})
|
})
|
||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for range 5 {
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
req, _ := http.NewRequest(http.MethodGet, "/test:action", nil)
|
req, _ := http.NewRequest(http.MethodGet, "/test:action", nil)
|
||||||
router.ServeHTTP(w, req)
|
router.ServeHTTP(w, req)
|
||||||
assert.Equal(t, http.StatusOK, w.Code)
|
assert.Equal(t, http.StatusOK, w.Code)
|
||||||
|
assert.Equal(t, "ok", w.Body.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = originalUpdate
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user