TestFileCache_TTL verifies that expired items are not returned.
(t *testing.T)
| 49 | |
| 50 | // TestFileCache_TTL verifies that expired items are not returned. |
| 51 | func TestFileCache_TTL(t *testing.T) { |
| 52 | c, err := NewFileCache(t.TempDir(), false) |
| 53 | if err != nil { |
| 54 | t.Fatalf("failed to create cache: %v", err) |
| 55 | } |
| 56 | |
| 57 | if setErr := c.Set("k", "v", time.Second); setErr != nil { |
| 58 | t.Fatalf("set: %v", setErr) |
| 59 | } |
| 60 | |
| 61 | time.Sleep(2 * time.Second) |
| 62 | |
| 63 | var s string |
| 64 | |
| 65 | found, err := c.Get("k", &s) |
| 66 | if err != nil { |
| 67 | t.Fatalf("get: %v", err) |
| 68 | } |
| 69 | |
| 70 | if found { |
| 71 | t.Fatalf("expected item to be expired") |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // TestFileCache_Persistence ensures data is loaded from disk when persisted. |
| 76 | func TestFileCache_Persistence(t *testing.T) { |
nothing calls this directly
no test coverage detected