Skip to content

Commit

Permalink
Check the objects created by the extension
Browse files Browse the repository at this point in the history
  • Loading branch information
rodo committed Dec 18, 2024
1 parent 0db6e70 commit e779b5f
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/sql/main_test.sql.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--
--
--
-- SELECT e.extname, ne.nspname AS extschema, p.proname, np.nspname AS proschema
-- FROM pg_catalog.pg_extension AS e
-- INNER JOIN pg_catalog.pg_depend AS d ON (d.refobjid = e.oid)
-- INNER JOIN pg_catalog.pg_proc AS p ON (p.oid = d.objid)
-- INNER JOIN pg_catalog.pg_namespace AS ne ON (ne.oid = e.extnamespace)
-- INNER JOIN pg_catalog.pg_namespace AS np ON (np.oid = p.pronamespace)
-- WHERE d.deptype = 'e'
-- ORDER BY 1, 3
DEALLOCATE PREPARE ALL;
SET search_path=public,pgtap;

BEGIN;

SELECT plan(2);

PREPARE count_functions AS
SELECT count(p.proname)::int
FROM pg_catalog.pg_extension AS e
INNER JOIN pg_catalog.pg_depend AS d ON (d.refobjid = e.oid)
INNER JOIN pg_catalog.pg_proc AS p ON (p.oid = d.objid)
WHERE d.deptype = 'e' AND extname = 'schedoc';


SELECT results_eq(
'count_functions',
$$VALUES (10)$$,
'We have the right number of functions');

--
-- Tables
--
PREPARE count_tables AS
SELECT count(e.extname)
FROM pg_catalog.pg_extension AS e
INNER JOIN pg_catalog.pg_depend AS d ON (d.refobjid = e.oid)
INNER JOIN pg_catalog.pg_class AS p ON (p.oid = d.objid)
WHERE d.deptype = 'e' AND e.extname = 'schedoc' AND p.relkind='r';

SELECT results_eq(
'count_tables',
$$VALUES (6)$$,
'We have the right number of functions');

SELECT finish();

ROLLBACK;

0 comments on commit e779b5f

Please sign in to comment.