pgTAP is a unit testing extension for PostgreSQL.
Let's cover some basic concepts:
- Unit tests: allow you to test small parts of a system (like a database table!).
- TAP: stands for Test Anything Protocol. It is an framework which aims to simplify the error reporting during testing.
Even though the SQL code is
create extension, this is the equivalent of "enabling the extension".
To disable an extension you can call
It's good practice to create the extension within a separate schema (like
extensions) to keep your database clean.
It's a good practice to keep all your tests in a separate schema.
- Create a plan
- We should come up with a recommendation on how to run the tests. Via a function? External scripts?
- Eventually this can be done via our CLI
Let's look at a few different tests which could be helpful in your project.