FakeBudgetStore
A scripted BudgetStore for tests, the worked example of the seam. Holds one snapshot (snapshot, preloaded through the constructor), counts calls, records every successful save, injects failures and delays.
Stable Core, source compatibility only. Thread-safe: one lock guards the state and is never held across a suspension. A delay is kotlinx.coroutines.delay in the caller's context, so it is virtual when the budget runs on the test scheduler, and a call the budget abandons at storeTimeout is cancelled in its delay and changes nothing (the store is cancellable, as the port requires).
Parameters
what the first load returns; BudgetSnapshot.Empty by default.
Properties
Functions
Counts the call in saveAttemptCount, waits saveDelay (virtual under a test scheduler), then stores snapshot and records it in saves, or delivers the failure armed by failSaves and stores nothing: returned in the Result, or thrown when it was armed with thrown = true. A save cancelled during the delay stores nothing.