Skip to content
Myr

test(route): add some test for routergroup (#4291)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by chenhuiluo · committed by GitHub · parent ae5be7f · Browse files · 1 file+24 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: chenhuiluo <luochenhui@butterfly.tech>

Diff stats

1 file+24 added−0 removed

  • other:+24 added−0 removed

1 file+24 added−0 removed

modified:routergroup_test.go+24 added
9 unmodified lines
1011 "github.com/stretchr/testify/assert"12)1314var MaxHandlers = 321516func init() {17 SetMode(TestMode)18}19
174 unmodified lines
194 assert.Equal(t, r, r.StaticFileFS("/static2", ".", Dir(".", false)))195 assert.Equal(t, r, r.Static("/static", "."))196 assert.Equal(t, r, r.StaticFS("/static2", Dir(".", false)))197}198199func TestRouterGroupCombineHandlersTooManyHandlers(t *testing.T) {200 group := &RouterGroup{201 Handlers: make(HandlersChain, MaxHandlers), // Assume group already has MaxHandlers middleware202 }203 tooManyHandlers := make(HandlersChain, MaxHandlers) // Add MaxHandlers more, total 2 * MaxHandlers204205 // This should trigger panic206 assert.Panics(t, func() {207 group.combineHandlers(tooManyHandlers)208 }, "should panic due to too many handlers")209}210211func TestRouterGroupCombineHandlersEmptySliceNotNil(t *testing.T) {212 group := &RouterGroup{213 Handlers: HandlersChain{},214 }215216 result := group.combineHandlers(HandlersChain{})217 assert.NotNil(t, result, "result should not be nil even with empty handlers")218 assert.Empty(t, result, "empty handlers should return empty chain")219}