What database risks should integration tests cover beyond checking that a row exists?
Answer
Check constraints, transactions, isolation, defaults, migrations, referential integrity, concurrent updates, encoding, time zones, audit fields and rollback behaviour. Validate through supported interfaces unless direct database access is explicitly part of the test objective.
Strong answer includes
- integrity and transactions
- concurrency and migrations
- appropriate observation layer
Practical example
Runs against the sample database, which intentionally contains one orphan order so the integrity query demonstrates a real failure.
Run the query to see the result.
A database integration check should verify invariants, not only that an INSERT produced a row. Use SQL to look for broken relationships and invalid persisted state, while separate tests exercise transaction rollback, isolation/concurrency, migrations, encoding and time-zone behavior through the supported application or database boundary.
Expected result: In the sample fixture the first query intentionally returns the orphan order; a healthy production integrity check should return zero rows. The persisted-state query should return zero rows.