github.com/msales/pkg/v3@v3.24.0/httpx/middleware/response_writer_test.go (about) 1 package middleware_test 2 3 import ( 4 "net/http/httptest" 5 "testing" 6 7 "github.com/msales/pkg/v3/httpx/middleware" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestResponseWriter_Status(t *testing.T) { 12 rw := middleware.NewResponseWriter(httptest.NewRecorder()) 13 14 assert.Equal(t, 0, rw.Status()) 15 16 rw.WriteHeader(123) 17 18 assert.Equal(t, 123, rw.Status()) 19 } 20 21 func TestResponseWriter_WriteStatus(t *testing.T) { 22 rw := middleware.NewResponseWriter(httptest.NewRecorder()) 23 24 assert.Equal(t, 0, rw.Status()) 25 26 rw.Write([]byte{}) 27 28 assert.Equal(t, 200, rw.Status()) 29 }