(t *testing.T)
| 358 | } |
| 359 | |
| 360 | func 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 | |
| 389 | func Test_manager_getRaw_Paths(t *testing.T) { |
| 390 | t.Parallel() |
nothing calls this directly
no test coverage detected