mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-05 02:18:15 +08:00
test(response_writer): add tests for ResponseWriter.Unwrap method
This commit is contained in:
parent
1fde3243c2
commit
675838ec99
@ -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