(t *testing.T)
| 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 | |
| 115 | func 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. |
| 131 | func newTestCache(t *testing.T) *DiskCache { |
| 132 | t.Helper() |
nothing calls this directly
no test coverage detected