MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestDiskCacheOpen

Function TestDiskCacheOpen

cmd/cache-proxy/cache_test.go:131–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

129
130// newTestCache creates a DiskCache backed by t.TempDir() for isolation.
131func newTestCache(t *testing.T) *DiskCache {
132 t.Helper()
133 c, err := NewDiskCache(t.TempDir(), 100)
134 if err != nil {
135 t.Fatalf("NewDiskCache: %v", err)
136 }
137 return c
138}
139
140func TestDiskCachePutGetHas(t *testing.T) {
141 c := newTestCache(t)
142 key := strings.Repeat("a", 64)
143 data := []byte("hello world")
144
145 if c.Has(key) {
146 t.Fatal("Has should be false before PutStream")
147 }
148 if _, _, ok := c.Open(key); ok {
149 t.Fatal("Open should miss before PutStream")
150 }
151 if _, err := c.PutStream(key, bytes.NewReader(data)); err != nil {
152 t.Fatalf("PutStream: %v", err)
153 }
154 if !c.Has(key) {
155 t.Fatal("Has should be true after PutStream")
156 }

Callers

nothing calls this directly

Calls 4

newTestCacheFunction · 0.85
PutMethod · 0.80
CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected