-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathstat_handler_wrapper_test.go
115 lines (108 loc) · 1.99 KB
/
stat_handler_wrapper_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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//go:build go1.8
// +build go1.8
package stats
import (
"net/http"
"testing"
)
func TestHTTPHandler_WrapResponse(t *testing.T) {
tests := []http.ResponseWriter{
struct {
http.ResponseWriter
http.Flusher
http.Hijacker
http.Pusher
http.CloseNotifier
}{},
struct {
http.ResponseWriter
http.Flusher
http.Hijacker
http.Pusher
}{},
struct {
http.ResponseWriter
http.Flusher
http.Hijacker
http.CloseNotifier
}{},
struct {
http.ResponseWriter
http.Flusher
http.Hijacker
}{},
struct {
http.ResponseWriter
http.Flusher
http.Pusher
http.CloseNotifier
}{},
struct {
http.ResponseWriter
http.Flusher
http.Pusher
}{},
struct {
http.ResponseWriter
http.Flusher
http.CloseNotifier
}{},
struct {
http.ResponseWriter
http.Flusher
}{},
struct {
http.ResponseWriter
http.Hijacker
http.Pusher
http.CloseNotifier
}{},
struct {
http.ResponseWriter
http.Hijacker
http.Pusher
}{},
struct {
http.ResponseWriter
http.Hijacker
http.CloseNotifier
}{},
struct {
http.ResponseWriter
http.Hijacker
}{},
struct {
http.ResponseWriter
http.Pusher
http.CloseNotifier
}{},
struct {
http.ResponseWriter
http.Pusher
}{},
struct {
http.ResponseWriter
http.CloseNotifier
}{},
struct{ http.ResponseWriter }{},
}
h := NewStatHandler(
NewStore(NewNullSink(), false),
http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})).(*httpHandler)
for i, test := range tests {
tc := test
_, canFlush := tc.(http.Flusher)
_, canHijack := tc.(http.Hijacker)
_, canPush := tc.(http.Pusher)
rw := h.wrapResponse(tc)
if _, ok := rw.(http.Flusher); ok != canFlush {
t.Errorf("Test(%d): Flusher: wanted %t", i, canFlush)
}
if _, ok := rw.(http.Hijacker); ok != canHijack {
t.Errorf("Test(%d): Hijacker: wanted %t", i, canHijack)
}
if _, ok := rw.(http.Pusher); ok != canPush {
t.Errorf("Test(%d): Pusher: wanted %t", i, canPush)
}
}
}