Skip to content

Commit

Permalink
add missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
iczc authored and ReneKroon committed Sep 7, 2021
1 parent 13ad080 commit b097d96
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,15 @@ func TestCacheGetWithTTL(t *testing.T) {
assert.NotNil(t, data, "Expected data to be not nil")
assert.Equal(t, nil, exists, "Expected data to exist")
assert.Equal(t, "world", (data.(string)), "Expected data content to be 'world'")
assert.Equal(t, ttl, orgttl, "Expected item TTL to be original TTL")

cache.SkipTTLExtensionOnHit(true)
cache.SetWithTTL("hello", "world", orgttl)
time.Sleep(10 * time.Millisecond)
data, ttl, exists = cache.GetWithTTL("hello")
assert.NotNil(t, data, "Expected data to be not nil")
assert.Equal(t, nil, exists, "Expected data to exist")
assert.Equal(t, "world", (data.(string)), "Expected data content to be 'world'")
assert.Less(t, ttl, orgttl, "Expected item TTL to be less than the original TTL")
assert.NotEqual(t, int(ttl), 0, "Expected item TTL to be not 0")
}
Expand Down

0 comments on commit b097d96

Please sign in to comment.