Improve router group tests (#2787)

This commit is contained in:
ziheng 2021-07-13 09:44:19 +08:00 committed by GitHub
parent f96678cb6b
commit caf2802593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -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...)
})
}