1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-01 22:09:21 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-06-03 07:50:24 -07:00
parent 5d3ea7014b
commit be5efe5927
2 changed files with 25 additions and 1 deletions

View File

@ -12,7 +12,7 @@ env:
before_install: before_install:
- export PATH=$PATH:$GOPATH/bin - export PATH=$PATH:$GOPATH/bin
- go get golang.org/x/tools/cmd/vet # - go get golang.org/x/tools/cmd/vet
- go get golang.org/x/tools/cmd/cover - go get golang.org/x/tools/cmd/cover
- go get github.com/modocache/gover - go get github.com/modocache/gover
- go get github.com/mattn/goveralls - go get github.com/mattn/goveralls

View File

@ -64,3 +64,27 @@ func TestResponse(t *testing.T) {
// reset // reset
r.reset(httptest.NewRecorder(), New()) r.reset(httptest.NewRecorder(), New())
} }
func TestResponseWriteCommit(t *testing.T) {
e := New()
w := httptest.NewRecorder()
r := NewResponse(w, e)
// Write body, it writes header if not committed yet
s := "echo"
r.Write([]byte(s))
assert.Equal(t, w.Code, 200)
assert.Equal(t, w.Body.String(), s)
assert.Equal(t, r.Status(), 200)
assert.Equal(t, r.Size(), int64(4))
assert.True(t, r.Committed())
// This is ignored with warning
r.WriteHeader(400)
assert.Equal(t, r.Status(), 200)
assert.Equal(t, r.Size(), int64(4))
assert.True(t, r.Committed())
}