Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Latest commit

 

History

History
59 lines (38 loc) · 1.58 KB

README.adoc

File metadata and controls

59 lines (38 loc) · 1.58 KB

Unit-tests for PostgreSQL (PL/pgSQL)

Features

  • ✓ works with managed PostgreSQL (does not require native extensions)

  • ✓ lots of matchers

  • ✓ nice console outputs

Usage

First specify a test inside test schema like this:

examples/my_first_test.sql
link:./examples/my_first_test.sql[role=include]

Then run all tests with:

run_all_tests.sql
link:./run_all_tests.sql[role=include]

API

Matchers

  • lib_test.assert_true(condition boolean)

  • lib_test.assert_true(message varchar, condition boolean)

  • lib_test.assert_false(condition boolean)

  • lib_test.assert_equal(left boolean, right boolean, message varchar default '')

  • lib_test.assert_equal(left integer, right integer, message varchar default '')

  • lib_test.assert_equal(left text, right text, message varchar default '')

  • lib_test.assert_equal(left jsonb, right jsonb, message varchar default '')

  • lib_test.assert_equal(left timestamptz, right timestamptz, message varchar default '')

  • lib_test.assert_equal(left uuid, right uuid, message varchar default '')

  • lib_test.assert_not_equal(left text, right text, message varchar default '')

  • lib_test.assert_null(val$ anyelement, message$ text default '')

  • lib_test.assert_not_null(val$ anyelement, message$ text default '')

  • lib_test.fail(varchar)

See ./matches.sql[matches]

Credits

  • pgunit for the inspiration and base code

SQL Conventions