Skip to main content

Module testing

Module testing 

Source
Expand description

Test doubles — MemoryConnection and fake_database.

A repository test should not need a database. This fake records the SQL a repository emits and replays queued rows, so the behaviour around the query — the hooks, the pagination arithmetic, the not-found handling, the shard route chosen — is testable with no server, schema or migration.

It is not a SQL engine: it never parses the statements it is given. Use it to test the layer above the ORM, and a real SQLite executor to test the SQL itself.

Structs§

MemoryConnection
A Connection that records statements and replays queued rows.
RecordedStatement
One recorded statement.

Functions§

fake_database
A Database over a MemoryConnection, plus a handle to the connection for assertions.