Skip to content

Commit

Permalink
Attempt to fix flakey announce test (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
codygibb committed Mar 11, 2019
1 parent af2ac4d commit 51def02
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/torrent/scheduler/announcer/announcer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package announcer

import (
"errors"
"runtime"
"testing"
"time"

Expand All @@ -39,6 +40,7 @@ func newMockEvents() *mockEvents {
func (e *mockEvents) AnnounceTick() { e.tick <- struct{}{} }

func (e *mockEvents) expectTick(t *testing.T) {
runtime.Gosched()
select {
case <-e.tick:
case <-time.After(500 * time.Millisecond):
Expand All @@ -47,6 +49,7 @@ func (e *mockEvents) expectTick(t *testing.T) {
}

func (e *mockEvents) expectNoTick(t *testing.T) {
runtime.Gosched()
select {
case <-e.tick:
require.FailNow(t, "Unexpected tick")
Expand Down

0 comments on commit 51def02

Please sign in to comment.