Unit testing in ParadeDB verifies that vector-search functions, embeddings, and index operations behave as expected before code reaches production.
Unit tests catch logic errors in vector similarity searches, ensure embedding pipelines stay deterministic, and prevent regressions when indexes or extensions are upgraded.
pgTAP integrates seamlessly with PostgreSQL and ParadeDB, providing assertion helpers (ok
, is
, throws_ok
) that run inside transactions and roll back automatically.
Run CREATE EXTENSION pgtap;
in the target database, then grant usage to your CI user. No ParadeDB-specific binaries are required.
Wrap assertions between SELECT plan(n);
and SELECT finish();
. Use ParadeDB functions inside assertions to validate vector distances, ANN index usage, or embedding correctness.
ok(boolean, note)
asserts truth; is(actual, expected, note)
checks equality; is_deeply(jsonb, jsonb, note)
compares JSON; throws_ok(sql, pattern, note)
expects errors.
Yes. pgTAP automatically runs each file in its own savepoint. Add an explicit ROLLBACK;
after tests if you script manually.
Use pg_prove
or pg_tap_runner
in GitHub Actions. Point it at test/
SQL files; it will fail the build on any non-zero tap result.
Seed small, deterministic fixtures; use SET enable_seqscan = off;
to force index usage; clean up with TRUNCATE
inside the test.
Do not forget plan()
; missing it marks every test as TODO. Avoid leaving data committed—wrap tests in transactions.
Yes. As long as you can CREATE EXTENSION pgtap;
, tests run the same way. Use a separate test database to avoid production data.
Keep fixtures small—10-20 vectors are enough to validate similarity logic and performance hints. Large datasets slow CI without increasing coverage.