From 919eaf1e9a1606febd061ca249c22af84536557f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B3=96=E6=B0=B4=E4=B8=8D=E5=8A=A0=E7=B3=96?= <641008175@qq.com> Date: Fri, 7 Aug 2020 14:05:21 +0800 Subject: [PATCH] adjust TestCache_Expire_SetVar Test Code. --- os/gcache/gcache_z_unit_1_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/os/gcache/gcache_z_unit_1_test.go b/os/gcache/gcache_z_unit_1_test.go index a9683a1ff..dd4a384e3 100644 --- a/os/gcache/gcache_z_unit_1_test.go +++ b/os/gcache/gcache_z_unit_1_test.go @@ -75,24 +75,25 @@ func TestCache_Set_Expire(t *testing.T) { func TestCache_Expire_SetVar(t *testing.T) { gtest.C(t, func(t *gtest.T) { - gcache.Set(1, 11, 3*time.Second) - expireBefore, okBefore := gcache.GetExpire(1) + cache := gcache.New() + cache.Set(1, 11, 3*time.Second) + expireBefore, okBefore := cache.GetExpire(1) if okBefore { t.AssertGT(expireBefore, 0) } - t.Assert(gcache.Get(1), 11) - gcache.SetVar(1, 12) - t.Assert(gcache.Get(1), 12) + t.Assert(cache.Get(1), 11) + cache.SetVar(1, 12) + t.Assert(cache.Get(1), 12) time.Sleep(1 * time.Second) - gcache.SetExpire(1, 5*time.Second) - expireAfter, okAfter := gcache.GetExpire(1) + cache.SetExpire(1, 5*time.Second) + expireAfter, okAfter := cache.GetExpire(1) if okAfter { t.Assert(expireAfter-expireBefore, 3000) } time.Sleep(4 * time.Second) - t.Assert(gcache.Get(1), 12) + t.Assert(cache.Get(1), 12) time.Sleep(2 * time.Second) - t.Assert(gcache.Get(1), nil) + t.Assert(cache.Get(1), nil) }) }