(t *testing.T)
| 387 | } |
| 388 | |
| 389 | func TestExpire(t *testing.T) { |
| 390 | cache := NewCache(1024) |
| 391 | key := []byte("abcd") |
| 392 | val := []byte("efgh") |
| 393 | err := cache.Set(key, val, 1) |
| 394 | if err != nil { |
| 395 | t.Error("err should be nil") |
| 396 | } |
| 397 | time.Sleep(time.Second) |
| 398 | val, err = cache.Get(key) |
| 399 | if err == nil { |
| 400 | t.Fatal("key should be expired", string(val)) |
| 401 | } |
| 402 | |
| 403 | cache.ResetStatistics() |
| 404 | if cache.ExpiredCount() != 0 { |
| 405 | t.Error("expired count should be zero.") |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | func TestTTL(t *testing.T) { |
| 410 | t.Run("with no expire key", testTTLWithNoExpireKey) |
nothing calls this directly
no test coverage detected
searching dependent graphs…