Merge 675838ec999411f1ed5b3e3d88de0e6f483824a2 into 3b08cd7235bd5ad2f055aa9e38135f111f6c5926

This commit is contained in:
Raju Ahmed 2026-09-24 12:07:17 +08:00 committed by GitHub
commit 12571be3c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -44,6 +44,9 @@ type ResponseWriter interface {
// Pusher get the http.Pusher for server push
Pusher() http.Pusher
// Unwrap get the underlying http.ResponseWriter
Unwrap() http.ResponseWriter
}
type responseWriter struct {

View File

@ -56,12 +56,23 @@ func init() {
SetMode(TestMode)
}
// test for ResponseWriter.Unwrap
func TestResponseWriterUnwrap(t *testing.T) {
testWriter := httptest.NewRecorder()
writer := &responseWriter{ResponseWriter: testWriter}
assert.Same(t, testWriter, writer.Unwrap())
}
func TestResponseWriterUnwrapViaInterface(t *testing.T) {
testWriter := httptest.NewRecorder()
writer := &responseWriter{}
writer.reset(testWriter)
var w ResponseWriter = writer
unwrapped := w.Unwrap()
assert.Same(t, testWriter, unwrapped)
}
func TestResponseWriterReset(t *testing.T) {
testWriter := httptest.NewRecorder()
writer := &responseWriter{}