Skip to main content

Module test_utils

Module test_utils 

Source
Expand description

Schema fixtures and crash checkpoints for tests of the production database.

Structs§

Connection
The connection an app’s test opens outside any store, for the coven crate to name in its own make_readable_objects. A connection to a SQLite database.
Followed
A live query’s results as a test follows them: each in the order the query reports it, kept as the latest one seen.
StatementLog
The statements that reads ran on the connections this log was given to, in order, from when each connection got it. Clones share one log.
TestAuthorship
Authorship of test writes, sealed and hashed with one fixed test key for every audience. It opens headers it sealed itself and checks no signature: the database checks roots and openings; sync checks signatures (D9).
WorkCounter
Injected counter; clones observe the same database, never other test databases.
WorkCounts
Local database work observed at its execution boundaries.

Enums§

OutcomeListing
How an operation a test ends outside a store reaches coven_operations: listed from its start, which the outcome then completes, or listed only as it ends, under kind.
WriteCheckpoint
Boundaries after a local write’s durable commit, for process-crash tests.

Functions§

finish_outside_store
End the operation id on connection, a test’s connection outside any store, with the outcome listing holds. For an operation that coven_operations lists already, the function sets its outcome, as finish_with_outcome does. For one it doesn’t list, the function lists the outcome under kind first, as list_outcome does when a refusal ends an invite. The function then deletes the operation’s pending record and its journal row, as finish does. Outside a store no operation holds a claim, so the function checks none.
idle_writers
Writers for a test not about forgetting kept records: one other device that can still write but never lands a write, so every kept record stays (§16.7).
journal_outside_store
Journal new on connection, a test’s connection outside any store, as insert does, and list it in coven_operations as insert_for_app does when listed_as names its kind.
make_readable_objects
Make on connection, a connection an app’s test opened itself outside any store, every object of coven’s that app SQL may read, as every store makes it: the tables the app’s local triggers may follow, coven_sync_status and coven_retry_effect with their one row, and coven’s views. The function also makes the tables of coven’s own that the views read or that the outside-store writes fill, all empty (readable_schema). The function registers coven’s SQL functions, with device as this device’s id and sync_functions as the computations of the sync state and of each upload’s phase, which the coven crate passes from sync as its builder does. Nothing transfers files there and nothing watches the network, as on a read-only handle. The test runs this function before the app’s schema, so the app’s triggers and views apply and run as in a store. coven writes no rows on that connection. coven’s triggers that keep coven_pending run there, and the test saves pending records with save_outside_store. The test writes the rows that coven would write in the other followed tables, and records a user’s original with record_user_file.
notes_migrations
The corresponding app migration sequence.
notes_tables
Declarations for a UUID-keyed notes table in the store audience.
record_user_file
Record on connection, where make_readable_objects made coven’s objects, the original at path, last modified at modified_at and holding bytes, as file’s original on this device, as staging it for the cloud records it: its size, modification time, content hash and chunk hashes (§17.3). coven_user_files then lists it.
report_cost
One measured number, as a line scripts/perf.sh reads: COST metric=<name> value=<n> unit=<ms|ratio|count>. Lower is better in every unit. A character in metric outside letters, digits and _./- becomes _, so a caller can pass a label unchanged.
report_time
report_cost for a time, in milliseconds.
save_last_pass_outside_store
Write last_pass as how the last pass ended on connection, a test’s connection outside any store, as save_last_pass does.
save_location_outside_store
Write location as the recorded location on connection, a test’s connection outside any store, as save_location does.
save_outside_store
Save record on connection, a test’s connection outside any store, as save does, so that coven’s triggers show it in coven_pending.
signer
Fixed member key used to authenticate fixture writes.
stage_plaintext
Stage a snapshot’s whole plaintext from input, one chunk at a time, as sync stages an opened body (§16.2).