Database testing
Plug-and-play skills and prompts for every AI coding agent
npx -y skills add Amey-Thakur/AI-SKILLS --skill database-testingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 20 days oldThe repository was created 20 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Exercise data-access code, migrations, and transactions against the real database engine so constraints, rollbacks, and schema changes are proven rather than assumed. Use when tests for queries or migrations run on SQLite while production runs Postgres.
SKILL.md
2.7 KB, 532 tokens by cl100k_base, as published. Nobody here has run it
Database testing
Data code fails on the specifics an ORM hides: the dialect a query compiles to, the constraint that fires on a duplicate, the migration that locks a table under load. A test against SQLite when production runs Postgres proves your mock of the database, not the database. Run against the real engine and the surprises show up in CI instead of at 3 a.m.
Method
- Run against the production engine and version. Start Postgres 16 (or whatever prod runs) with Testcontainers or a docker-compose fixture, not SQLite. Dialect differences in JSON operators, upserts, and case sensitivity are exactly where the bugs are.
- Test migrations both directions. Apply the up migration to an empty schema, assert the tables and indexes exist, then apply the down and assert it returns clean. A down migration nobody runs is a rollback that fails during an incident.
- Isolate each test in a transaction and roll back. Open a transaction in setup, run the test, roll back in teardown. This keeps tests order-independent and fast, and no test sees rows another one wrote.
- Prove the constraints fire. Insert a duplicate against a unique index, an orphan against a foreign key, a null into a NOT NULL column, and assert the IntegrityError. A constraint no test triggers is a comment, not a guarantee.
- Verify rollback on partial failure. Drive a multi-statement unit of work that errors midway and assert nothing persisted. An application-level transaction that leaves half its writes behind is the classic data-corruption bug.
- Test concurrency where the code relies on it. For
SELECT FOR UPDATE, optimistic version columns, or a chosen isolation level, run two concurrent transactions and assert the serialization failure or the correct winner, not just the single-threaded path.
Checks
- Do the tests run on the same engine and major version as production?
- Does a broken migration or a violated constraint fail a test rather than pass silently?
- After a mid-transaction error, does an assertion confirm zero rows landed?
Boundaries
This is the persistence layer under your code. The HTTP surface above it belongs to api-testing, cross-service seams to integration-testing, and the shape of the schema itself to schema-design. Reuse the project's fixture and container setup instead of standing up a parallel one.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.