Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improve concurrent test
  • Loading branch information
bep committed Dec 26, 2024
commit 7a741fc5e4233ecc7e6bcb6f0b6b1024253fa5c4
8 changes: 6 additions & 2 deletions lazycache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,13 @@ func TestGetOrCreateConcurrent(t *testing.T) {
go func() {
defer wg.Done()
for j := 0; j < 12; j++ {
countersmu.Lock()
_, created := counters[i]
countersmu.Unlock()
res, found := cache.Get(i)
// The value may be nil if if GetOrCreate has not been called for i yet.
if found {
if !found {
c.Assert(created, qt.IsFalse)
} else {
c.Assert(res, qt.Equals, expect)
}
}
Expand Down
Loading