mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-27 17:23:00 +00:00
Added timeouts to gateway integration tests
This commit is contained in:
parent
345ef44e6c
commit
a3a914ac4a
|
@ -6,6 +6,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestIntegration(t *testing.T) {
|
||||
|
@ -27,7 +28,7 @@ func TestIntegration(t *testing.T) {
|
|||
}
|
||||
gateway = g
|
||||
|
||||
ready, ok := (<-gateway.Events).(*ReadyEvent)
|
||||
ready, ok := wait(t, gateway.Events).(*ReadyEvent)
|
||||
if !ok {
|
||||
t.Fatal("Event received is not of type Ready:", ready)
|
||||
}
|
||||
|
@ -50,8 +51,18 @@ func TestIntegration(t *testing.T) {
|
|||
}
|
||||
*/
|
||||
|
||||
ready, ok = (<-gateway.Events).(*ReadyEvent)
|
||||
ready, ok = wait(t, gateway.Events).(*ReadyEvent)
|
||||
if !ok {
|
||||
t.Fatal("Event received is not of type Ready:", ready)
|
||||
}
|
||||
}
|
||||
|
||||
func wait(t *testing.T, evCh chan interface{}) interface{} {
|
||||
select {
|
||||
case ev := <-evCh:
|
||||
return ev
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Fatal("Timed out waiting for event")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue