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

Function TestIsValidCacheKey

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

Source from the content-addressed store, hash-verified

50 t.Fatalf("read histogram: %v", err)
51 }
52 return m.GetHistogram().GetSampleCount()
53}
54
55// errAfterReader yields n bytes then returns a non-EOF error, simulating an
56// origin/peer connection dropping mid-body.
57type errAfterReader struct {
58 data []byte
59 pos int
60}
61
62func (e *errAfterReader) Read(p []byte) (int, error) {
63 if e.pos >= len(e.data) {
64 return 0, errors.New("connection reset mid-stream")
65 }
66 n := copy(p, e.data[e.pos:])
67 e.pos += n
68 return n, nil
69}
70
71type scriptedCacheDirectory struct {
72 entries []os.DirEntry
73 err error
74 read bool
75}
76
77func (d *scriptedCacheDirectory) ReadDir(int) ([]os.DirEntry, error) {
78 if !d.read {
79 d.read = true
80 return d.entries, nil
81 }

Callers

nothing calls this directly

Calls 1

IsValidCacheKeyFunction · 0.85

Tested by

no test coverage detected