From 9b800d7184a434af168b6ec03addfe79999285a5 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 15 Feb 2018 21:34:37 +0000 Subject: [PATCH] vfs: fix race in cache tests --- vfs/cache_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vfs/cache_test.go b/vfs/cache_test.go index 6ef959862..bda264ab4 100644 --- a/vfs/cache_test.go +++ b/vfs/cache_test.go @@ -133,14 +133,18 @@ name="potato" isFile=true opens=1`, itemAsString(c)) // updateAtimes - not in the cache oldItem := item + c.itemMu.Lock() delete(c.item, "potato") // remove from cache + c.itemMu.Unlock() err = c.updateAtimes() require.NoError(t, err) assert.Equal(t, `name="" isFile=false opens=1 name="potato" isFile=true opens=0`, itemAsString(c)) item = c.get("potato") assert.Equal(t, atime, item.atime) + c.itemMu.Lock() c.item["potato"] = oldItem // restore to cache + c.itemMu.Unlock() // try purging with file open c.purgeOld(10 * time.Second)