pgtap
pgtap : Unit testing for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3200 | pgtap | pgtap | 1.3.4 |
LANG | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| Requires | plpgsql |
| Need By | pgsqlmock |
| See Also | faker dbt2 pg_mockable pgsqlmock omni_test random tsm_system_time tsm_system_rows |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 1.3.4 |
18 17 16 15 14 | pgtap |
plpgsql |
| RPM | PGDG | 1.3.4 |
18 17 16 15 14 | pgtap_$v |
- |
| DEB | PGDG | 1.3.4 |
18 17 16 15 14 | postgresql-$v-pgtap |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| el8.aarch64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| el9.x86_64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| el9.aarch64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| el10.x86_64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| el10.aarch64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| d12.x86_64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| d12.aarch64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| d13.x86_64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| d13.aarch64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| u22.x86_64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| u22.aarch64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| u24.x86_64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| u24.aarch64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| u26.x86_64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
| u26.aarch64 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 | PGDG 1.3.4 |
Source
github.com/theory/pgtap
Install
Make sure PGDG repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
pgtap is a unit testing framework for PostgreSQL that produces TAP (Test Anything Protocol) output, providing hundreds of assertion functions for testing database objects and query results.
Test Structure
Use no_plan() when the test count is not known in advance:
Basic Assertions
Schema Testing
Error Testing
Query Result Testing
Running Tests with pg_prove
xUnit Style
Version 1.3.4 and Test Boundaries
Version 1.3.4 adds index_is_partial() and name/name overloads of has_composite() and hasnt_composite(), and repairs several older upgrade paths. Install the matching scripts before ALTER EXTENSION pgtap UPDATE TO '1.3.4'. The control file requires plpgsql, sets superuser = false, and permits relocation; shared preload is unnecessary. A role still needs CREATE on the database and suitable privileges for the objects a test exercises.
Run tests against disposable fixtures or an isolated test database. Transaction rollback does not undo external actions performed by the functions being tested. The pg_prove client must be installed separately; extension installation alone does not provide that runner.