Fix WebSocket close

This commit is contained in:
178inaba 2017-04-30 22:14:02 +09:00
parent 70b3dbf548
commit fc574ac209
2 changed files with 14 additions and 3 deletions

View file

@ -106,13 +106,12 @@ func wsMock(w http.ResponseWriter, r *http.Request) {
func wsTest(t *testing.T, q chan Event, cancel func()) {
time.AfterFunc(time.Second, func() {
cancel()
close(q)
})
events := []Event{}
for e := range q {
events = append(events, e)
}
if len(events) != 4 {
if len(events) != 6 {
t.Fatalf("result should be four: %d", len(events))
}
if events[0].(*UpdateEvent).Status.Content != "foo" {
@ -127,6 +126,12 @@ func wsTest(t *testing.T, q chan Event, cancel func()) {
if errorEvent, ok := events[3].(*ErrorEvent); !ok {
t.Fatalf("should be fail: %v", errorEvent.err)
}
if errorEvent, ok := events[4].(*ErrorEvent); !ok {
t.Fatalf("should be fail: %v", errorEvent.err)
}
if errorEvent, ok := events[5].(*ErrorEvent); !ok {
t.Fatalf("should be fail: %v", errorEvent.err)
}
}
func TestStreamingWS(t *testing.T) {