Open cardillomarcelo opened 3 weeks ago
ctx.Status() does not affect httptest.ResponseRecorder while ctx.JSON() does
package main import ( "fmt" "github.com/gin-gonic/gin" "net/http" "net/http/httptest" "testing" ) func TestName(t *testing.T) { recorder := httptest.NewRecorder() c, _ := gin.CreateTestContext(recorder) changeResponseCode(c) fmt.Println(recorder.Code) } func changeResponseCode(ctx *gin.Context) { ctx.Status(http.StatusNoContent) }
Should print 204
Prints 200
c.Status(204) do not change the recorder.status but change responseWriter.status
c.Status(204)
recorder.status
responseWriter.status
Description
ctx.Status() does not affect httptest.ResponseRecorder while ctx.JSON() does
How to reproduce
Expectations
Actual result
Environment