1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-03 22:52:19 +02:00
echo/response_test.go
Vishal Rana 13ac746093 Refactored Echo.HandlerFunc, added WebSocket support.
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-05-20 14:38:51 -07:00

41 lines
733 B
Go

package echo
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestResponse(t *testing.T) {
r := NewResponse(httptest.NewRecorder())
// Header
if r.Header() == nil {
t.Error("header should not be nil")
}
// WriteHeader
r.WriteHeader(http.StatusOK)
if r.status != http.StatusOK {
t.Errorf("status should be %d", http.StatusOK)
}
if r.committed != true {
t.Error("response should be true")
}
// Response already committed
r.WriteHeader(http.StatusOK)
// Status
r.status = http.StatusOK
if r.Status() != http.StatusOK {
t.Errorf("status should be %d", http.StatusOK)
}
// Write & Size
s := "echo"
r.Write([]byte(s))
if r.Size() != int64(len(s)) {
t.Errorf("size should be %d", len(s))
}
}