testing library

Test doubles and checks for code that logs or extends the library: RecordingLogSink records entries and lifecycle calls in place of a mock, which the base LogSink does not allow; compareLogStores checks a LogStore implementation against the in-memory reference over a random scenario (LogStoreScenario) and reports where they disagree. Depends on no test framework. Separate from log_trail.dart so that application code does not see it.

Classes

LogStoreContractCheck
Drives a store under test and a reference store (normally InMemoryLogStore with the same limit) in lockstep through a LogStoreScenario and collects where they disagree. compareLogStores runs it whole; a test that drives several stores through one scenario (two scoped stores over one table) calls round and finish itself.
LogStoreMismatch
One place where a store under compareLogStores disagreed with the reference.
LogStoreScenario
Random entries and queries for compareLogStores: the scenario every LogStore implementation is checked against.
RecordingLogSink
A sink for tests: records what it receives and counts the lifecycle calls.

Functions

compareLogStores(LogStore store, {required LogStore reference, required int seed, int rounds = 12, bool compareIds = true}) → Future<List<LogStoreMismatch>>
Checks store against the LogStore contract by comparing it with reference (an InMemoryLogStore with the same limit, whose queryInMemory and LogCondition.matches define the semantics) over rounds rounds of the LogStoreScenario for seed. Returns the mismatches; an empty list means the store behaved like the reference for this seed. A package's contract test runs a few seeds and asserts the list is empty: