Skip to content

Commit dbd3150

Browse files
committed
test/finish.sql: use set_hasnt() instead of a hand-rolled ok()
pgTAP's set_hasnt() asserts a set has none of a given set of values, which is exactly what the search_path check needs, and reports which schema leaked into search_path on failure instead of just failing. Split into two assertions, one per schema, so a failure names the specific schema.
1 parent 090e5c1 commit dbd3150

13 files changed

Lines changed: 35 additions & 22 deletions

test/expected/_object_v.out

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
\set ECHO none
2-
1..2
2+
1..3
33
ok 1 - _object_v__for_update matches _object_v
4-
ok 2 - object_reference schema(s) must not be part of the resolved search_path
4+
ok 2 - object_reference schema must not be part of the resolved search_path
5+
ok 3 - _object_reference schema must not be part of the resolved search_path
56
# TRANSACTION INTENTIONALLY LEFT OPEN!

test/expected/all.out

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
\set ECHO none
2-
1..74
2+
1..75
33
ok 1 - All object types are being tested.
44
ok 2 - Verify object_reference.unsupported()
55
ok 3 - prereq: CREATE DOMAIN "test domain" int
@@ -73,5 +73,6 @@ ok 70 - DROP index "test table test index"
7373
ok 71 - Drop should fail while reference exists
7474
ok 72 - DROP table "test table"
7575
ok 73 - No object references remain
76-
ok 74 - object_reference schema(s) must not be part of the resolved search_path
76+
ok 74 - object_reference schema must not be part of the resolved search_path
77+
ok 75 - _object_reference schema must not be part of the resolved search_path
7778
# TRANSACTION INTENTIONALLY LEFT OPEN!

test/expected/base.out

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
\set ECHO none
2-
1..11
2+
1..12
33
ok 1 - Role object_reference__dependency should be granted USAGE on schema _object_reference
44
ok 2 - Role object_reference__dependency should be granted REFERENCES on table _object_reference.object
55
ok 3 - CREATE TEMP TABLE test_object AS SELECT object_reference.object__getsert('table', 'test_table') AS object_id;
@@ -10,5 +10,6 @@ ok 7 - Existing object works, provides correct ID
1010
ok 8 - secondary may not be specified for table objects
1111
ok 9 - temp objects are rejected
1212
ok 10 - CREATE EXTENSION test_factory
13-
ok 11 - object_reference schema(s) must not be part of the resolved search_path
13+
ok 11 - object_reference schema must not be part of the resolved search_path
14+
ok 12 - _object_reference schema must not be part of the resolved search_path
1415
# TRANSACTION INTENTIONALLY LEFT OPEN!

test/expected/capture.out

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
\set ECHO none
2-
1..70
2+
1..71
33
ok 1 - prereq: CREATE DOMAIN "test domain" int
44
ok 2 - prereq: CREATE FUNCTION tg_null() RETURNS trigger LANGUAGE plpgsql AS $body$BEGIN RETURN NEW; END$body$
55
ok 3 - prereq: CREATE TYPE "test type"
@@ -69,5 +69,6 @@ ok 66 - Drop should fail while reference exists
6969
ok 67 - DROP table "test table"
7070
ok 68 - object_group_ids still has correct record count
7171
ok 69 - No object references remain
72-
ok 70 - object_reference schema(s) must not be part of the resolved search_path
72+
ok 70 - object_reference schema must not be part of the resolved search_path
73+
ok 71 - _object_reference schema must not be part of the resolved search_path
7374
# TRANSACTION INTENTIONALLY LEFT OPEN!

test/expected/event_trigger.out

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
\set ECHO none
2-
1..43
2+
1..44
33
ok 1 - Register schema-drop test objects
44
ok 2 - Create objects_view
55
ok 3 - Exactly 3 test view records
@@ -42,5 +42,6 @@ ok 39 - Verify filler column record is deleted
4242
ok 40 - Verify objects still registered correctly
4343
ok 41 - Drop schema
4444
ok 42 - objects_view is empty
45-
ok 43 - object_reference schema(s) must not be part of the resolved search_path
45+
ok 43 - object_reference schema must not be part of the resolved search_path
46+
ok 44 - _object_reference schema must not be part of the resolved search_path
4647
# TRANSACTION INTENTIONALLY LEFT OPEN!

test/expected/object_group.out

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
\set ECHO none
2-
1..30
2+
1..31
33
ok 1 - Register test table 1
44
ok 2 - object_group__create(...) for group name that is too long throws error
55
ok 3 - object_group__create('object reference test group')
@@ -29,5 +29,6 @@ ok 26 - Object exists before cleanup test
2929
ok 27 - Remove from group triggers automatic cleanup attempt
3030
ok 28 - Object was automatically cleaned up after group removal
3131
ok 29 - Removing empty group works
32-
ok 30 - object_reference schema(s) must not be part of the resolved search_path
32+
ok 30 - object_reference schema must not be part of the resolved search_path
33+
ok 31 - _object_reference schema must not be part of the resolved search_path
3334
# TRANSACTION INTENTIONALLY LEFT OPEN!

test/finish.sql

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Asserts object_reference's own schema(s) are absent from the resolved
2+
* Asserts object_reference's own schemas are absent from the resolved
33
* search_path -- checked here (file end, before finish()) rather than only
44
* at setup, so a test that mutates search_path mid-file and never restores
55
* it is caught. Not foolproof: mutate-then-restore before this line still
@@ -13,9 +13,16 @@
1313
* test in the suite passing means nothing accidentally relied on
1414
* search_path to resolve one of the extension's own objects.
1515
*/
16-
SELECT ok(
17-
NOT ( 'object_reference' = ANY (current_schemas(false)) OR '_object_reference' = ANY (current_schemas(false)) )
18-
, 'object_reference schema(s) must not be part of the resolved search_path'
16+
SELECT set_hasnt(
17+
$$ SELECT unnest(current_schemas(false)) $$
18+
, $$ VALUES ('object_reference') $$
19+
, 'object_reference schema must not be part of the resolved search_path'
20+
);
21+
22+
SELECT set_hasnt(
23+
$$ SELECT unnest(current_schemas(false)) $$
24+
, $$ VALUES ('_object_reference') $$
25+
, '_object_reference schema must not be part of the resolved search_path'
1926
);
2027

2128
\i test/pgxntool/finish.sql

test/sql/_object_v.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SELECT plan(
66
0
77

88
+ 1 -- equality
9-
+ 1 -- schema-qualification (search_path)
9+
+ 2 -- schema-qualification (search_path)
1010
);
1111

1212
-- TODO: load some damn data first

test/sql/all.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SELECT plan( (
2828
+ c * 2 -- drop
2929

3030
+ 1 -- verify object table is now empty
31-
+ 1 -- schema-qualification (search_path)
31+
+ 2 -- schema-qualification (search_path)
3232
)::int )
3333
FROM (SELECT count(*) c FROM test_object) c
3434
;

test/sql/base.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SELECT plan(
1111
+2 -- new functions
1212
+3 -- errors (includes temp object test)
1313
+1 -- create extensions
14-
+1 -- schema-qualification (search_path)
14+
+2 -- schema-qualification (search_path)
1515
);
1616

1717
-- Schema

0 commit comments

Comments
 (0)