forked from labstack/echo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
response_test.go
61 lines (46 loc) · 951 Bytes
/
response_test.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package echo
import (
"github.com/stretchr/testify/assert"
"net/http"
"net/http/httptest"
"testing"
)
func TestResponse(t *testing.T) {
w := httptest.NewRecorder()
r := NewResponse(w)
// SetWriter
r.SetWriter(w)
// Writer
assert.Equal(t, w, r.Writer())
// Header
assert.NotNil(t, r.Header())
// WriteHeader
r.WriteHeader(http.StatusOK)
assert.Equal(t, http.StatusOK, r.status)
// Committed
assert.True(t, r.committed)
// Already committed
r.WriteHeader(http.StatusTeapot)
assert.NotEqual(t, http.StatusTeapot, r.Status())
// Status
r.status = http.StatusOK
assert.Equal(t, http.StatusOK, r.Status())
// Write
s := "echo"
_, err := r.Write([]byte(s))
assert.NoError(t, err)
// Flush
r.Flush()
// Size
assert.EqualValues(t, len(s), r.Size())
// Hijack
assert.Panics(t, func() {
r.Hijack()
})
// CloseNotify
assert.Panics(t, func() {
r.CloseNotify()
})
// reset
r.reset(httptest.NewRecorder())
}