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

Function TestDiskCacheRejectsInvalidKey

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

Source from the content-addressed store, hash-verified

153 }
154 if !c.Has(key) {
155 t.Fatal("Has should be true after PutStream")
156 }
157 r, _, ok := c.Open(key)
158 if !ok {
159 t.Fatal("Open should hit after PutStream")
160 }
161 defer func() { _ = r.Close() }()
162 got, _ := io.ReadAll(r)
163 if string(got) != string(data) {
164 t.Errorf("Open returned %q, want %q", got, data)
165 }
166}
167
168func TestDiskCacheOpen(t *testing.T) {
169 c := newTestCache(t)
170 key := strings.Repeat("b", 64)
171 data := []byte("streaming bytes")
172 if _, err := c.PutStream(key, bytes.NewReader(data)); err != nil {
173 t.Fatalf("PutStream: %v", err)
174 }

Callers

nothing calls this directly

Calls 6

newTestCacheFunction · 0.85
HasMethod · 0.80
PutMethod · 0.80
ErrorMethod · 0.45
GetMethod · 0.45
OpenMethod · 0.45

Tested by

no test coverage detected