Skip to content

Commit a9162bf

Browse files
oliricedarora
authored andcommitted
postgis sql interface test
1 parent 9e1612c commit a9162bf

File tree

6 files changed

+824
-4
lines changed

6 files changed

+824
-4
lines changed

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@
421421
422422
#pg_prove -p 5432 -h localhost -d testing ${sqlTests}/*.sql
423423
424-
mkdir -p $out/regression_output
424+
mkdir -p $out/regression_output
425425
pg_regress \
426426
--use-existing \
427427
--dbname=testing \

nix/docs/adding-tests.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
11
There are basically two types of tests you can add:
22

33
- pgTAP based tests, and
4+
- pg\_regress tests
45
- Migration tests.
56

6-
In both cases, a number of extensions may be installed into the database for
7+
In all cases, a number of extensions may be installed into the database for
78
use; you can see those in both [postgresql.conf.in](../tests/postgresql.conf.in)
89
and [prime.sql](../tests/prime.sql) (extensions may be enabled in either place.)
910

11+
## pg\_regress tests
12+
13+
pg\_regress tests are in [tests/sql](./../tests/sql/) with output in [tests/expected](./../tests/expected/).
14+
To create a new test, create a new SQL file in [tests/sql](./../tests/sql/) and then run:
15+
16+
```
17+
nix flake check -L
18+
```
19+
20+
Next, review the logs to identify where the test output was written
21+
22+
```
23+
postgres> CREATE EXTENSION IF NOT EXISTS index_advisor;
24+
postgres> CREATE EXTENSION
25+
postgres> (using postmaster on localhost, port 5432)
26+
postgres> ============== running regression test queries ==============
27+
postgres> test new_test ... diff: /nix/store/5gk419ddz7mzzwhc9j6yj5i8lkw67pdl-tests/expected/new_test.out: No such file or directory
28+
postgres> diff command failed with status 512: diff "/nix/store/5gk419ddz7mzzwhc9j6yj5i8lkw67pdl-tests/expected/new_test.out" "/nix/store/2fbrvnnr7iz6yigyf0rb0vxnyqvrgxzp-postgres-15.6-check-harness/regression_output/results/new_test.out" > "/nix/store/2fbrvnnr7iz6yigyf0rb0vxnyqvrgxzp-postgres-15.6-check-harness/regression_output/results/new_test.out.diff
29+
```
30+
31+
and copy the `regression_output` directory to where you can review
32+
33+
```
34+
cp -r /nix/store/2fbrvnnr7iz6yigyf0rb0vxnyqvrgxzp-postgres-15.6-check-harness/regression_output .
35+
```
36+
37+
Then you can review the contents of `regression_output/results/new_test.out` to see if it matches what you expected.
38+
39+
If it does match your expectations, copy the file to [tests/expected](./../tests/expected/) and the test will pass on the next run.
40+
41+
If the output does not match your expectations, update the `<new_test>.sql` file, re-run with `nix flake check -L` and try again
42+
43+
1044
## pgTAP tests
1145

1246
These are super easy: simply add `.sql` files to the

0 commit comments

Comments
 (0)