Fix TestHandleReader
parent
517247284e
commit
088cb0b74d
|
@ -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 {
|
if !passUpdate || !passNotification || !passDelete || !passError {
|
||||||
t.Fatalf("have not passed through somewhere: update %t, notification %t, delete %t",
|
t.Fatalf("have not passed through somewhere: "+
|
||||||
passUpdate, passNotification, passDelete)
|
"update %t, notification %t, delete %t, error %t",
|
||||||
|
passUpdate, passNotification, passDelete, passError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue