Skip to content

Commit

Permalink
fix small failing worker pool test from v1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Jan 30, 2024
1 parent 6819b40 commit 8e451b2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions orchestrator/work/workerpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package work
import (
"context"
"testing"
"time"

"github.com/stretchr/testify/assert"
"go.uber.org/zap"
Expand All @@ -26,8 +27,17 @@ func Test_workerPoolPool_Borrow_Return(t *testing.T) {
assert.Len(t, pi.workers, 2)
assert.True(t, pi.WorkerAvailable())
worker1 := pi.Borrow()

// only one worker available until 4 seconds have passed
assert.False(t, pi.WorkerAvailable())

// after delay, all workers are available
newStarted := (*pi.started).Add(-5 * time.Second)
pi.started = &newStarted

assert.True(t, pi.WorkerAvailable())
worker2 := pi.Borrow()

assert.False(t, pi.WorkerAvailable())
assert.Panics(t, func() { pi.Borrow() })
pi.Return(worker2)
Expand Down

0 comments on commit 8e451b2

Please sign in to comment.