Remove impossible race conditions from test

This makes the output of go test --race less noisy.
This commit is contained in:
Karl Seguin
2020-08-16 19:07:52 +08:00
parent 0dbf3f125f
commit 839a17bedb
2 changed files with 11 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ package ccache
import (
"strconv"
"sync/atomic"
"testing"
"time"
@@ -81,10 +82,10 @@ func (_ CacheTests) DeletesAFunc() {
}
func (_ CacheTests) OnDeleteCallbackCalled() {
onDeleteFnCalled := false
onDeleteFnCalled := int32(0)
onDeleteFn := func(item *Item) {
if item.key == "spice" {
onDeleteFnCalled = true
atomic.AddInt32(&onDeleteFnCalled, 1)
}
}
@@ -98,7 +99,7 @@ func (_ CacheTests) OnDeleteCallbackCalled() {
Expect(cache.Get("spice")).To.Equal(nil)
Expect(cache.Get("worm").Value()).To.Equal("sand")
Expect(onDeleteFnCalled).To.Equal(true)
Expect(atomic.LoadInt32(&onDeleteFnCalled)).To.Eql(1)
}
func (_ CacheTests) FetchesExpiredItems() {