(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestFutureCache_Persistent(t *testing.T) { |
| 18 | c := newFutureCache[int, int](true) |
| 19 | ctx := context.Background() |
| 20 | |
| 21 | var computed atomic.Int32 |
| 22 | compute := func(i int) cacheFunc[int] { |
| 23 | return func(context.Context) (int, error) { |
| 24 | computed.Add(1) |
| 25 | return i, ctx.Err() |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | testFutureCache(t, ctx, c, compute) |
| 30 | |
| 31 | // Since this cache is persistent, we should get exactly 10 computations, |
| 32 | // since there are 10 distinct keys in [testFutureCache]. |
| 33 | if got := computed.Load(); got != 10 { |
| 34 | t.Errorf("computed %d times, want 10", got) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestFutureCache_Ephemeral(t *testing.T) { |
| 39 | c := newFutureCache[int, int](false) |
nothing calls this directly
no test coverage detected
searching dependent graphs…