forked from labstack/echo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse_test.go
More file actions
40 lines (34 loc) · 733 Bytes
/
response_test.go
File metadata and controls
40 lines (34 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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))
}
}