Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
3DRX committed Jul 9, 2024
1 parent a0af181 commit c6d27a9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/route/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,3 +1029,33 @@ func TestAcquireHijackConn(t *testing.T) {
assert.DeepEqual(t, engine, hijackConn.e)
assert.DeepEqual(t, conn, hijackConn.Conn)
}

func TestHandleParamsReassignInHandleFunc(t *testing.T) {
e := NewEngine(config.NewOptions(nil))
ctx := app.NewContext(3)
routes := []string{
"/:a/:b/:c",
}
for _, r := range routes {
e.GET(r, func(c context.Context, ctx *app.RequestContext) {
ctx.Params = make([]param.Param, 1)
ctx.String(consts.StatusOK, "")
})
}
testRoutes := []string{
"/aaa/bbb/ccc",
"/asd/alskja/alkdjad",
"/asd/alskja/alkdjad",
"/asd/alskja/alkdjad",
"/asd/alskja/alkdjad",
"/alksjdlakjd/ooo/askda",
"/alksjdlakjd/ooo/askda",
"/alksjdlakjd/ooo/askda",
}
for _, tr := range testRoutes {
r := protocol.NewRequest(http.MethodGet, tr, nil)
r.CopyTo(&ctx.Request)
e.ServeHTTP(context.Background(), ctx)
ctx.ResetWithoutConn()
}
}

0 comments on commit c6d27a9

Please sign in to comment.