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
InMemoryLogStorewith the samelimit) 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
storeagainst the LogStore contract by comparing it withreference(anInMemoryLogStorewith the samelimit, whosequeryInMemoryand LogCondition.matches define the semantics) overroundsrounds of the LogStoreScenario forseed. 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: