Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Explicit, not auto-detected: fail loudly if test/install/ ever ends up
# empty by accident, rather than silently falling back to per-test install.
PGXNTOOL_ENABLE_TEST_INSTALL = yes

include pgxntool/base.mk

# Temporary hack
Expand Down
8 changes: 7 additions & 1 deletion test/core/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ BEGIN
END
$body$;

SET SEARCH_PATH = _null_count_test, tap, :schema;
/*
* No explicit target schema to restore in phase 1 (count_nulls installs
* with no schema targeting at all - see test/install/load.sql), so this
* just re-states the same search_path already set at the top of this file.
* A later schema-targeting phase may need this to do more.
*/
SET SEARCH_PATH = _null_count_test, tap;

-- vi: expandtab sw=2 ts=2
12 changes: 5 additions & 7 deletions test/deps.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
-- Add any test dependency statements here
-- IF NOT EXISTS will emit NOTICEs, which is annoying
SET client_min_messages = WARNING;
CREATE SCHEMA IF NOT EXISTS :schema;
SET search_path = :schema;
SET client_min_messages = NOTICE;

CREATE EXTENSION count_nulls;
--
-- count_nulls itself is no longer installed here: test/install/load.sql
-- installs it once, committed, before any test/sql/*.sql file runs (see
-- pgxntool/README.asc's "test/install" section) - so it's already present
-- by the time this per-test (rolled-back) file loads.
94 changes: 46 additions & 48 deletions test/expected/extension_tests.out
Original file line number Diff line number Diff line change
@@ -1,87 +1,85 @@
\set ECHO none
# Subtest: _null_count_test.test__check_ncs()
ok 1
ok 2 - schema schema_to_load_count_nulls should not be in search path
1..2
ok 1 - ncs() resolves to the schema count_nulls actually installed in
1..1
ok 1 - _null_count_test.test__check_ncs
# Subtest: _null_count_test.test__definition()
ok 1 - ensure null_count({anyarray}) is not in search_path
ok 2 - Function schema_to_load_count_nulls.null_count(anyarray) should return integer
ok 3 - Function schema_to_load_count_nulls.null_count(anyarray) should not be strict
ok 4 - Function schema_to_load_count_nulls.null_count(anyarray) should be IMMUTABLE
ok 2 - Function public.null_count(anyarray) should return integer
ok 3 - Function public.null_count(anyarray) should not be strict
ok 4 - Function public.null_count(anyarray) should be IMMUTABLE
ok 5 - ensure null_count({json}) is not in search_path
ok 6 - Function schema_to_load_count_nulls.null_count(json) should return integer
ok 7 - Function schema_to_load_count_nulls.null_count(json) should not be strict
ok 8 - Function schema_to_load_count_nulls.null_count(json) should be IMMUTABLE
ok 6 - Function public.null_count(json) should return integer
ok 7 - Function public.null_count(json) should not be strict
ok 8 - Function public.null_count(json) should be IMMUTABLE
ok 9 - ensure null_count({jsonb}) is not in search_path
ok 10 - Function schema_to_load_count_nulls.null_count(jsonb) should return integer
ok 11 - Function schema_to_load_count_nulls.null_count(jsonb) should not be strict
ok 12 - Function schema_to_load_count_nulls.null_count(jsonb) should be IMMUTABLE
ok 10 - Function public.null_count(jsonb) should return integer
ok 11 - Function public.null_count(jsonb) should not be strict
ok 12 - Function public.null_count(jsonb) should be IMMUTABLE
ok 13 - ensure not_null_count({anyarray}) is not in search_path
ok 14 - Function schema_to_load_count_nulls.not_null_count(anyarray) should return integer
ok 15 - Function schema_to_load_count_nulls.not_null_count(anyarray) should not be strict
ok 16 - Function schema_to_load_count_nulls.not_null_count(anyarray) should be IMMUTABLE
ok 14 - Function public.not_null_count(anyarray) should return integer
ok 15 - Function public.not_null_count(anyarray) should not be strict
ok 16 - Function public.not_null_count(anyarray) should be IMMUTABLE
ok 17 - ensure not_null_count({json}) is not in search_path
ok 18 - Function schema_to_load_count_nulls.not_null_count(json) should return integer
ok 19 - Function schema_to_load_count_nulls.not_null_count(json) should not be strict
ok 20 - Function schema_to_load_count_nulls.not_null_count(json) should be IMMUTABLE
ok 18 - Function public.not_null_count(json) should return integer
ok 19 - Function public.not_null_count(json) should not be strict
ok 20 - Function public.not_null_count(json) should be IMMUTABLE
ok 21 - ensure not_null_count({jsonb}) is not in search_path
ok 22 - Function schema_to_load_count_nulls.not_null_count(jsonb) should return integer
ok 23 - Function schema_to_load_count_nulls.not_null_count(jsonb) should not be strict
ok 24 - Function schema_to_load_count_nulls.not_null_count(jsonb) should be IMMUTABLE
ok 25 - Function schema_to_load_count_nulls.null_count_trigger() should return trigger
ok 26 - Function schema_to_load_count_nulls.null_count_trigger() should not be strict
ok 27 - Function schema_to_load_count_nulls.null_count_trigger() should be IMMUTABLE
ok 28 - Function schema_to_load_count_nulls.not_null_count_trigger() should return trigger
ok 29 - Function schema_to_load_count_nulls.not_null_count_trigger() should not be strict
ok 30 - Function schema_to_load_count_nulls.not_null_count_trigger() should be IMMUTABLE
ok 22 - Function public.not_null_count(jsonb) should return integer
ok 23 - Function public.not_null_count(jsonb) should not be strict
ok 24 - Function public.not_null_count(jsonb) should be IMMUTABLE
ok 25 - Function public.null_count_trigger() should return trigger
ok 26 - Function public.null_count_trigger() should not be strict
ok 27 - Function public.null_count_trigger() should be IMMUTABLE
ok 28 - Function public.not_null_count_trigger() should return trigger
ok 29 - Function public.not_null_count_trigger() should not be strict
ok 30 - Function public.not_null_count_trigger() should be IMMUTABLE
1..30
ok 2 - _null_count_test.test__definition
# Subtest: _null_count_test.test__functionality()
ok 1 - Test schema_to_load_count_nulls.null_count(a, b, c)
ok 2 - Test schema_to_load_count_nulls.null_count(json)
ok 3 - Test schema_to_load_count_nulls.null_count(jsonb)
ok 4 - CREATE TRIGGER "test trigger" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.not_null_count_trigger( NULL )
ok 5 - Test schema_to_load_count_nulls.not_null_count_trigger( NULL )
ok 1 - Test public.null_count(a, b, c)
ok 2 - Test public.null_count(json)
ok 3 - Test public.null_count(jsonb)
ok 4 - CREATE TRIGGER "test trigger" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.not_null_count_trigger( NULL )
ok 5 - Test public.not_null_count_trigger( NULL )
ok 6 - DROP TRIGGER "test trigger"
ok 7 - CREATE TRIGGER "test trigger" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.not_null_count_trigger( )
ok 8 - Test schema_to_load_count_nulls.not_null_count_trigger( )
ok 7 - CREATE TRIGGER "test trigger" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.not_null_count_trigger( )
ok 8 - Test public.not_null_count_trigger( )
ok 9 - DROP TRIGGER "test trigger"
ok 10 - CREATE TRIGGER "test trigger" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.null_count_trigger( NULL )
ok 11 - Test schema_to_load_count_nulls.null_count_trigger( NULL )
ok 10 - CREATE TRIGGER "test trigger" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.null_count_trigger( NULL )
ok 11 - Test public.null_count_trigger( NULL )
ok 12 - DROP TRIGGER "test trigger"
ok 13 - CREATE TRIGGER "test trigger" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.null_count_trigger( )
ok 14 - Test schema_to_load_count_nulls.null_count_trigger( )
ok 13 - CREATE TRIGGER "test trigger" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.null_count_trigger( )
ok 14 - Test public.null_count_trigger( )
ok 15 - DROP TRIGGER "test trigger"
ok 16 - CREATE TRIGGER "null_BEFORE_error_message" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.null_count_trigger(1, 'error_message')
ok 16 - CREATE TRIGGER "null_BEFORE_error_message" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.null_count_trigger(1, 'error_message')
ok 17 - Test "null_BEFORE_error_message"
ok 18 - DROP TRIGGER "null_BEFORE_error_message"
ok 19 - CREATE TRIGGER "null_AFTER_error_message" AFTER INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.null_count_trigger(1, 'error_message')
ok 19 - CREATE TRIGGER "null_AFTER_error_message" AFTER INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.null_count_trigger(1, 'error_message')
ok 20 - Test "null_AFTER_error_message"
ok 21 - DROP TRIGGER "null_AFTER_error_message"
ok 22 - CREATE TRIGGER "not_null_BEFORE_error_message" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.not_null_count_trigger(1, 'error_message')
ok 22 - CREATE TRIGGER "not_null_BEFORE_error_message" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.not_null_count_trigger(1, 'error_message')
ok 23 - Test "not_null_BEFORE_error_message"
ok 24 - DROP TRIGGER "not_null_BEFORE_error_message"
ok 25 - CREATE TRIGGER "not_null_AFTER_error_message" AFTER INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.not_null_count_trigger(1, 'error_message')
ok 25 - CREATE TRIGGER "not_null_AFTER_error_message" AFTER INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.not_null_count_trigger(1, 'error_message')
ok 26 - Test "not_null_AFTER_error_message"
ok 27 - DROP TRIGGER "not_null_AFTER_error_message"
ok 28 - CREATE TRIGGER "null_BEFORE_" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.null_count_trigger(1, NULL)
ok 28 - CREATE TRIGGER "null_BEFORE_" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.null_count_trigger(1, NULL)
ok 29 - Test "null_BEFORE_"
ok 30 - DROP TRIGGER "null_BEFORE_"
ok 31 - CREATE TRIGGER "null_AFTER_" AFTER INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.null_count_trigger(1, NULL)
ok 31 - CREATE TRIGGER "null_AFTER_" AFTER INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.null_count_trigger(1, NULL)
ok 32 - Test "null_AFTER_"
ok 33 - DROP TRIGGER "null_AFTER_"
ok 34 - CREATE TRIGGER "not_null_BEFORE_" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.not_null_count_trigger(1, NULL)
ok 34 - CREATE TRIGGER "not_null_BEFORE_" BEFORE INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.not_null_count_trigger(1, NULL)
ok 35 - Test "not_null_BEFORE_"
ok 36 - DROP TRIGGER "not_null_BEFORE_"
ok 37 - CREATE TRIGGER "not_null_AFTER_" AFTER INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE schema_to_load_count_nulls.not_null_count_trigger(1, NULL)
ok 37 - CREATE TRIGGER "not_null_AFTER_" AFTER INSERT ON test_data FOR EACH ROW EXECUTE PROCEDURE public.not_null_count_trigger(1, NULL)
ok 38 - Test "not_null_AFTER_"
ok 39 - DROP TRIGGER "not_null_AFTER_"
1..39
ok 3 - _null_count_test.test__functionality
# Subtest: _null_count_test.test__shutdown__drop_all()
ok 1
ok 2
1..2
1..1
ok 4 - _null_count_test.test__shutdown__drop_all
1..4
12 changes: 0 additions & 12 deletions test/expected/sanity.out

This file was deleted.

71 changes: 0 additions & 71 deletions test/expected/simple.out

This file was deleted.

2 changes: 2 additions & 0 deletions test/install/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
load.out
install.out.diff
12 changes: 12 additions & 0 deletions test/install/load.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Installs count_nulls once, committed, before the main test/sql/ schedule
-- runs (see pgxntool/README.asc's "test/install" and "Update & Upgrade (U&U)
-- Testing" sections) - so every test/sql/*.sql file finds it already
-- present instead of each one installing (and dropping) it per-test.
--
-- This file's own output is NOT tracked as expected output (see
-- test/install/.gitignore): pg_regress resolves both its expected and
-- actual-result paths to test/install/load.out, so the diff is always
-- self-identical regardless of content. Correctness here comes from this
-- file failing loudly (aborting the session) if something's wrong, not
-- from a textual comparison - matching cat_tools' test/install/load.sql.
CREATE EXTENSION count_nulls;
30 changes: 12 additions & 18 deletions test/sql/extension_tests.sql
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
\set ECHO none

\set schema schema_to_load_count_nulls
\i test/load.sql

\set schema public
\i test/core/functions.sql

--CREATE OR REPLACE FUNCTION ncs() RETURNS name LANGUAGE sql IMMUTABLE AS $$SELECT 'schema_to_load_count_nulls'::name$$;

/*
* count_nulls is installed by test/install/load.sql with no schema
* targeting - it lands wherever the session's own search_path resolves at
* CREATE EXTENSION time (in-suite, that's pgTap's own schema, put on
* search_path first by test/pgxntool/tap_setup.sql). This just proves
* ncs() actually resolves to something real; a future TEST_SCHEMA switch
* (see pgxntool/README.asc's U&U section) would let this assert an exact,
* known location instead.
*/
CREATE FUNCTION _null_count_test.test__check_ncs
() RETURNS SETOF text LANGUAGE plpgsql AS $body$
DECLARE
s CONSTANT name = 'schema_to_load_count_nulls';
BEGIN
RETURN NEXT is(
RETURN NEXT isnt(
ncs()
, s
);
RETURN NEXT is(
current_schemas(true) @> array[s]
, false
--, format('schema %I should not be in search path (%s)', s, current_schemas(true))
, format('schema %I should not be in search path', s) --, current_schemas(true))
, NULL
, 'ncs() resolves to the schema count_nulls actually installed in'
);
END
$body$;
Expand All @@ -32,10 +30,6 @@ BEGIN
RETURN NEXT lives_ok(
$$DROP EXTENSION count_nulls$$
);

RETURN NEXT lives_ok(
$$DROP SCHEMA schema_to_load_count_nulls$$
);
END
$body$;

Expand Down
11 changes: 0 additions & 11 deletions test/sql/sanity.sql

This file was deleted.

11 changes: 0 additions & 11 deletions test/sql/simple.sql

This file was deleted.

Loading