Skip to content

Commit

Permalink
chore(pool): better assertions in stats test
Browse files Browse the repository at this point in the history
  • Loading branch information
redbaron authored and jackc committed Aug 14, 2024
1 parent c419363 commit ee87cc3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ func TestPoolStatSuccessfulAcquireCounters(t *testing.T) {
stat := pool.Stat()
assert.Equal(t, int64(1), stat.AcquireCount())
assert.Equal(t, int64(1), stat.EmptyAcquireCount())
assert.True(t, stat.AcquireDuration() > 0, "expected stat.AcquireDuration() > 0 but %v", stat.AcquireDuration())
assert.Positive(t, stat.AcquireDuration(), "expected stat.AcquireDuration() > 0 but %v", stat.AcquireDuration())
assert.Equal(t, stat.EmptyAcquireWaitTime(), stat.AcquireDuration())
lastAcquireDuration := stat.AcquireDuration()

Expand All @@ -692,8 +692,8 @@ func TestPoolStatSuccessfulAcquireCounters(t *testing.T) {
stat = pool.Stat()
assert.Equal(t, int64(2), stat.AcquireCount())
assert.Equal(t, int64(1), stat.EmptyAcquireCount())
assert.True(t, stat.AcquireDuration() > lastAcquireDuration)
assert.True(t, stat.EmptyAcquireWaitTime() < stat.AcquireDuration())
assert.Greater(t, stat.AcquireDuration(), lastAcquireDuration)
assert.Less(t, stat.EmptyAcquireWaitTime(), stat.AcquireDuration())
lastAcquireDuration = stat.AcquireDuration()

wg := &sync.WaitGroup{}
Expand All @@ -713,8 +713,8 @@ func TestPoolStatSuccessfulAcquireCounters(t *testing.T) {
stat = pool.Stat()
assert.Equal(t, int64(4), stat.AcquireCount())
assert.Equal(t, int64(2), stat.EmptyAcquireCount())
assert.True(t, stat.AcquireDuration() > lastAcquireDuration)
assert.True(t, stat.EmptyAcquireWaitTime() < stat.AcquireDuration())
assert.Greater(t, stat.AcquireDuration(), lastAcquireDuration)
assert.Less(t, stat.EmptyAcquireWaitTime(), stat.AcquireDuration())
lastAcquireDuration = stat.AcquireDuration()
}

Expand Down

0 comments on commit ee87cc3

Please sign in to comment.