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

Function TestDiskCachePutGetHas

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

Source from the content-addressed store, hash-verified

103 {strings.Repeat("a", 60) + "/../x", false},
104 // Non-hex chars.
105 {strings.Repeat("g", 64), false},
106 {strings.Repeat("z", 64), false},
107 }
108 for _, c := range cases {
109 if got := IsValidCacheKey(c.key); got != c.want {
110 t.Errorf("IsValidCacheKey(%q) = %v, want %v", c.key, got, c.want)
111 }
112 }
113}
114
115func TestCacheKeyDeterministic(t *testing.T) {
116 a := CacheKey("", "http://s3/bucket/file.parquet", "bytes=0-1023")
117 b := CacheKey("", "http://s3/bucket/file.parquet", "bytes=0-1023")
118 if a != b {
119 t.Fatalf("CacheKey not deterministic: %s != %s", a, b)
120 }
121 if !IsValidCacheKey(a) {
122 t.Errorf("CacheKey output %q is not a valid key", a)
123 }
124 c := CacheKey("", "http://s3/bucket/file.parquet", "bytes=0-2047")
125 if a == c {
126 t.Fatal("different ranges produced identical keys")
127 }
128}
129
130// newTestCache creates a DiskCache backed by t.TempDir() for isolation.
131func newTestCache(t *testing.T) *DiskCache {
132 t.Helper()

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected