MCPcopy
hub / github.com/gofiber/fiber / Test_manager_get_StorageErrors

Function Test_manager_get_StorageErrors

middleware/cache/coverage_test.go:360–387  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

358}
359
360func Test_manager_get_StorageErrors(t *testing.T) {
361 t.Parallel()
362
363 // Storage GetWithContext returns an error.
364 storage := newFailingCacheStorage()
365 storage.errs["get|k"] = errors.New("boom")
366 m := newManager(storage, true)
367 _, err := m.get(context.Background(), "k")
368 require.ErrorContains(t, err, redactedKey)
369
370 // Stored bytes fail to unmarshal.
371 storage2 := newFailingCacheStorage()
372 storage2.data["k"] = []byte{0xff, 0xff, 0xff}
373 m2 := newManager(storage2, false)
374 _, err = m2.get(context.Background(), "k")
375 require.ErrorContains(t, err, "unmarshal")
376
377 // Cache miss.
378 m3 := newManager(newFailingCacheStorage(), false)
379 _, err = m3.get(context.Background(), "missing")
380 require.ErrorIs(t, err, errCacheMiss)
381
382 // Memory-backed unexpected type.
383 m4 := newManager(nil, false)
384 m4.memory.Set("k", "not-an-item", time.Minute)
385 _, err = m4.get(context.Background(), "k")
386 require.ErrorContains(t, err, "unexpected entry type")
387}
388
389func Test_manager_getRaw_Paths(t *testing.T) {
390 t.Parallel()

Callers

nothing calls this directly

Calls 5

newFailingCacheStorageFunction · 0.85
newManagerFunction · 0.70
NewMethod · 0.65
SetMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected