Skip to content

Commit

Permalink
🚨 Test(End): Add timeout test for c.End()
Browse files Browse the repository at this point in the history
  • Loading branch information
grivera64 committed Jan 13, 2025
1 parent 1ea8944 commit 5747064
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5949,6 +5949,21 @@ func Test_Ctx_End(t *testing.T) {
require.Equal(t, "Hello, World!", string(body))
}

// go test -run Test_Ctx_End_after_timeout
func Test_Ctx_End_after_timeout(t *testing.T) {
app := New()

// Early flushing handler
app.Get("/", func(c Ctx) error {
time.Sleep(2 * time.Second)
return c.End()
})

resp, err := app.Test(httptest.NewRequest(MethodGet, "/", nil))
require.ErrorIs(t, err, os.ErrDeadlineExceeded)
require.Nil(t, resp)
}

// go test -run Test_Ctx_End_with_drop_middleware
func Test_Ctx_End_with_drop_middleware(t *testing.T) {
app := New()
Expand Down

0 comments on commit 5747064

Please sign in to comment.