MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestFileCache_TTL

Function TestFileCache_TTL

internal/cache/cache_test.go:51–73  ·  view source on GitHub ↗

TestFileCache_TTL verifies that expired items are not returned.

(t *testing.T)

Source from the content-addressed store, hash-verified

49
50// TestFileCache_TTL verifies that expired items are not returned.
51func 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.
76func TestFileCache_Persistence(t *testing.T) {

Callers

nothing calls this directly

Calls 3

SetMethod · 0.95
GetMethod · 0.95
NewFileCacheFunction · 0.85

Tested by

no test coverage detected