make test fail instead of hang
Jeromy committed
Oct 14, 2014 at 17:46 UTC
1a7fac45514aa26fccb1dc7d8821146947d2e440
1 file changed
+11
-2
routing/dht/dht_test.go
+11
-2
@@ -431,6 +431,15 @@ func TestConnectCollision(t *testing.T) {
431
done <- struct{}{}
432
}()
433
434
- <-done
435
- <-done
434
+ timeout := time.After(time.Second * 5)
435
+ select {
436
+ case <-done:
437
+ case <-timeout:
438
+ t.Fatal("Timeout received!")
439
+ }
440
+ select {
441
+ case <-done:
442
+ case <-timeout:
443
+ t.Fatal("Timeout received!")
444
+ }
445
}