mirror of
https://github.com/gin-gonic/gin.git
synced 2026-04-30 15:48:17 +08:00
Merge 675838ec999411f1ed5b3e3d88de0e6f483824a2 into d3ffc9985281dcf4d3bef604cce4e662b1a327a6
This commit is contained in:
commit
172bc77cdf
@ -44,6 +44,9 @@ type ResponseWriter interface {
|
|||||||
|
|
||||||
// Pusher get the http.Pusher for server push
|
// Pusher get the http.Pusher for server push
|
||||||
Pusher() http.Pusher
|
Pusher() http.Pusher
|
||||||
|
|
||||||
|
// Unwrap get the underlying http.ResponseWriter
|
||||||
|
Unwrap() http.ResponseWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
type responseWriter struct {
|
type responseWriter struct {
|
||||||
|
|||||||
@ -33,12 +33,23 @@ func init() {
|
|||||||
SetMode(TestMode)
|
SetMode(TestMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test for ResponseWriter.Unwrap
|
||||||
func TestResponseWriterUnwrap(t *testing.T) {
|
func TestResponseWriterUnwrap(t *testing.T) {
|
||||||
testWriter := httptest.NewRecorder()
|
testWriter := httptest.NewRecorder()
|
||||||
writer := &responseWriter{ResponseWriter: testWriter}
|
writer := &responseWriter{ResponseWriter: testWriter}
|
||||||
assert.Same(t, testWriter, writer.Unwrap())
|
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) {
|
func TestResponseWriterReset(t *testing.T) {
|
||||||
testWriter := httptest.NewRecorder()
|
testWriter := httptest.NewRecorder()
|
||||||
writer := &responseWriter{}
|
writer := &responseWriter{}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user