chore: add unit test for WithCodeResponseWriter (#5028)

Signed-off-by: kevin <wanjunfeng@gmail.com>
This commit is contained in:
Kevin Wan
2025-07-25 21:45:47 +08:00
committed by GitHub
parent 0be63c3625
commit 25f37ca750
5 changed files with 44 additions and 30 deletions

View File

@@ -46,3 +46,15 @@ func TestWithCodeResponseWriter_Hijack(t *testing.T) {
writer.Hijack()
})
}
func TestWithCodeResponseWriter_Unwrap(t *testing.T) {
resp := httptest.NewRecorder()
writer := NewWithCodeResponseWriter(resp)
unwrapped := writer.Unwrap()
assert.Equal(t, resp, unwrapped)
// Test with a nested WithCodeResponseWriter
nestedWriter := NewWithCodeResponseWriter(writer)
unwrappedNested := nestedWriter.Unwrap()
assert.Equal(t, resp, unwrappedNested)
}