TestOverlayCacheURLKey verifies that the cache key is the URL only, and that a cached memory blob is correctly retrieved by URL.
(t *testing.T)
| 337 | // TestOverlayCacheURLKey verifies that the cache key is the URL only, and that |
| 338 | // a cached memory blob is correctly retrieved by URL. |
| 339 | func TestOverlayCacheURLKey(t *testing.T) { |
| 340 | cache, err := newImageCache(50 * 1024 * 1024) |
| 341 | require.NoError(t, err) |
| 342 | |
| 343 | blob := makeTestMemBlob(100, 100, 4) |
| 344 | data, _, _, _, _ := blob.Memory() |
| 345 | cache.Set("logo.png", blob, int64(len(data))) |
| 346 | cache.Wait() |
| 347 | |
| 348 | got, found := cache.Get("logo.png") |
| 349 | assert.True(t, found, "blob should be found by URL key") |
| 350 | assert.Equal(t, blob, got, "retrieved blob should match stored blob") |
| 351 | |
| 352 | // A different URL must not collide. |
| 353 | _, found2 := cache.Get("other.png") |
| 354 | assert.False(t, found2, "different URL must not collide") |
| 355 | } |
| 356 | |
| 357 | // TestOverlayCacheAnimatedSkipped verifies that animated overlays |
| 358 | // (img.Height() != img.PageHeight()) are served but not stored in the cache. |
nothing calls this directly
no test coverage detected