MCPcopy Index your code
hub / github.com/cshum/imagor / TestOverlayCacheURLKey

Function TestOverlayCacheURLKey

processor/vipsprocessor/overlay_test.go:339–355  ·  view source on GitHub ↗

TestOverlayCacheURLKey verifies that the cache key is the URL only, and that a cached memory blob is correctly retrieved by URL.

(t *testing.T)

Source from the content-addressed store, hash-verified

337// TestOverlayCacheURLKey verifies that the cache key is the URL only, and that
338// a cached memory blob is correctly retrieved by URL.
339func 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.

Callers

nothing calls this directly

Calls 5

newImageCacheFunction · 0.85
makeTestMemBlobFunction · 0.85
MemoryMethod · 0.80
SetMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected