Skip to content

Commit

Permalink
Improve router group tests (#2787)
Browse files Browse the repository at this point in the history
  • Loading branch information
zihengCat authored Jul 13, 2021
1 parent f96678c commit caf2802
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions routergroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,19 @@ func TestRouterGroupInvalidStaticFile(t *testing.T) {
}

func TestRouterGroupTooManyHandlers(t *testing.T) {
const (
panicValue = "too many handlers"
maximumCnt = abortIndex
)
router := New()
handlers1 := make([]HandlerFunc, 40)
handlers1 := make([]HandlerFunc, maximumCnt-1)
router.Use(handlers1...)

handlers2 := make([]HandlerFunc, 26)
assert.Panics(t, func() {
handlers2 := make([]HandlerFunc, maximumCnt+1)
assert.PanicsWithValue(t, panicValue, func() {
router.Use(handlers2...)
})
assert.Panics(t, func() {
assert.PanicsWithValue(t, panicValue, func() {
router.GET("/", handlers2...)
})
}
Expand Down

0 comments on commit caf2802

Please sign in to comment.