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

netwo-io/lib_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

PL/pgSQL unit-test library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published