From 088cb0b74d36a101f78c5b756d9c6797d3d76ff2 Mon Sep 17 00:00:00 2001 From: 178inaba <178inaba@users.noreply.github.com> Date: Sun, 30 Apr 2017 03:19:58 +0900 Subject: [PATCH] Fix TestHandleReader --- streaming_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/streaming_test.go b/streaming_test.go index a417580..1ee1655 100644 --- a/streaming_test.go +++ b/streaming_test.go @@ -14,6 +14,8 @@ func TestHandleReader(t *testing.T) { q := make(chan Event) r := strings.NewReader(` event: update +data: {content: error} +event: update data: {"content": "foo"} event: notification data: {"type": "mention"} @@ -28,7 +30,7 @@ data: 1234567 t.Fatalf("should not be fail: %v", err) } }() - var passUpdate, passNotification, passDelete bool + var passUpdate, passNotification, passDelete, passError bool for e := range q { switch event := e.(type) { case *UpdateEvent: @@ -46,11 +48,17 @@ data: 1234567 if event.ID != 1234567 { t.Fatalf("want %d but %d", 1234567, event.ID) } + case *ErrorEvent: + passError = true + if event.err == nil { + t.Fatalf("should be fail: %v", event.err) + } } } - if !passUpdate || !passNotification || !passDelete { - t.Fatalf("have not passed through somewhere: update %t, notification %t, delete %t", - passUpdate, passNotification, passDelete) + if !passUpdate || !passNotification || !passDelete || !passError { + t.Fatalf("have not passed through somewhere: "+ + "update %t, notification %t, delete %t, error %t", + passUpdate, passNotification, passDelete, passError) } }