Fix TestHandleReader

pull/50/head
178inaba 2017-04-30 03:19:58 +09:00
parent 517247284e
commit 088cb0b74d
1 changed files with 12 additions and 4 deletions

View File

@ -14,6 +14,8 @@ func TestHandleReader(t *testing.T) {
q := make(chan Event) q := make(chan Event)
r := strings.NewReader(` r := strings.NewReader(`
event: update event: update
data: {content: error}
event: update
data: {"content": "foo"} data: {"content": "foo"}
event: notification event: notification
data: {"type": "mention"} data: {"type": "mention"}
@ -28,7 +30,7 @@ data: 1234567
t.Fatalf("should not be fail: %v", err) t.Fatalf("should not be fail: %v", err)
} }
}() }()
var passUpdate, passNotification, passDelete bool var passUpdate, passNotification, passDelete, passError bool
for e := range q { for e := range q {
switch event := e.(type) { switch event := e.(type) {
case *UpdateEvent: case *UpdateEvent:
@ -46,11 +48,17 @@ data: 1234567
if event.ID != 1234567 { if event.ID != 1234567 {
t.Fatalf("want %d but %d", 1234567, event.ID) 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", if !passUpdate || !passNotification || !passDelete || !passError {
passUpdate, passNotification, passDelete) t.Fatalf("have not passed through somewhere: "+
"update %t, notification %t, delete %t, error %t",
passUpdate, passNotification, passDelete, passError)
} }
} }