Another attempt to fix FullBus test

This commit is contained in:
ErickSkrauch 2020-04-26 21:05:54 +03:00
parent b2e501af60
commit 585318d307

View File

@ -236,8 +236,8 @@ func TestPeriodicStrategy(t *testing.T) {
strategy.Queue(j)
ctx, cancel := context.WithCancel(context.Background())
ch := strategy.GetJobs(ctx)
startedAt := time.Now()
ch := strategy.GetJobs(ctx)
iteration := <-ch
durationBeforeResult := time.Now().Sub(startedAt)
require.True(t, durationBeforeResult >= d)
@ -371,9 +371,10 @@ func TestFullBusStrategy(t *testing.T) {
d := 20 * time.Millisecond
strategy := NewFullBusStrategy(d, 10)
ctx, cancel := context.WithCancel(context.Background())
startedAt := time.Now()
ch := strategy.GetJobs(ctx)
var startedAt time.Time
done := make(chan struct{})
go func() {
defer close(done)
@ -385,7 +386,6 @@ func TestFullBusStrategy(t *testing.T) {
require.Equal(t, 0, iteration.Queue)
}()
startedAt = time.Now()
for _, j := range jobs {
strategy.Queue(j)
}