From fdb9829e38a759669673364c34ae7b175b0504d3 Mon Sep 17 00:00:00 2001 From: dmitry Date: Thu, 30 Nov 2017 15:31:14 +0200 Subject: [PATCH] rewriting cache to sync.Map and make all cache tests work --- cache_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cache_test.go b/cache_test.go index 2819374..1758253 100644 --- a/cache_test.go +++ b/cache_test.go @@ -1762,9 +1762,13 @@ func TestGetWithExpiration(t *testing.T) { } else if e2 := x.(int); e2+2 != 3 { t.Error("e (which should be 1) plus 2 does not equal 3; value:", e2) } - //if expiration.UnixNano() != tc.items["e"].Expiration { - // t.Error("expiration for e is not the correct time") - //} + tmp, ok := tc.items.Load("e") + if ok { + e := tmp.(Item) + if expiration.UnixNano() != e.Expiration { + t.Error("expiration for e is not the correct time") + } + } if expiration.UnixNano() < time.Now().UnixNano() { t.Error("expiration for e is in the past") }