Skip to content

Commit 90f86ee

Browse files
Merge branch 'decibel:master' into ci
2 parents 0875521 + 10554ce commit 90f86ee

7 files changed

Lines changed: 65 additions & 3 deletions

File tree

sql/test_factory.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE TEMP TABLE original_role ON COMMIT DROP AS SELECT current_user AS original_role;
2+
23
GRANT SELECT ON pg_temp.original_role TO public;
34
DO $body$
45
BEGIN

sql/test_factory_pgtap.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ BEGIN
3535
END
3636
$body$;
3737

38+
DROP TABLE pg_temp.original_role;
39+
3840
-- vi: expandtab ts=2 sw=2

test/deps.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- IF NOT EXISTS will emit NOTICEs, which is annoying
2+
SET client_min_messages = WARNING;
3+
4+
-- Add any test dependency statements here
5+
-- Note: pgTap is loaded by setup.sql
6+
--CREATE EXTENSION IF NOT EXISTS ...;
7+
/*
8+
* Now load our extension. We don't use IF NOT EXISTs here because we want an
9+
* error if the extension is already loaded (because we want to ensure we're
10+
* getting the very latest version).
11+
*/
12+
CREATE EXTENSION ...;
13+
14+
-- Re-enable notices
15+
SET client_min_messages = NOTICE;

test/expected/install.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
\set ECHO none
2+
ok 1 - drop extension test_factory_pgtap
3+
ok 2 - drop extension test_factory
4+
ok 3 - Extension test_factory should not exist
5+
ok 4 - Extension test_factory_pgtap should not exist
6+
ok 5 - create extension
7+
ok 6 - Function tf.tap(text, text) should exist
8+
ok 7 - clean-up test_factory_pgtap
9+
ok 8 - clean-up test_factory

test/helpers/tap_setup.sql

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
\i test/helpers/psql.sql
22

3-
CREATE SCHEMA tap;
3+
/*
4+
* NOTE: if you get errors about things already existing it's because they've
5+
* been left behind by test/sql/install.sql
6+
*/
7+
SET client_min_messages = WARNING;
8+
CREATE SCHEMA IF NOT EXISTS tap;
49
SET search_path = tap;
510
CREATE EXTENSION IF NOT EXISTS pgtap SCHEMA tap;
6-
--\i test/helpers/pgtap-core.sql
7-
--\i test/helpers/pgtap-schema.sql
11+
SET client_min_messages = NOTICE;
812

913
\pset format unaligned
1014
\pset tuples_only true

test/pgxntool

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../pgxntool/test/pgxntool

test/sql/install.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
\set ECHO none
2+
\i test/helpers/setup.sql
3+
4+
SET client_min_messages = WARNING;
5+
6+
/*
7+
* DO NOT use CASCADE here; we want this to fail if there's anything installed
8+
* that depends on it.
9+
*/
10+
SELECT lives_ok($$DROP EXTENSION IF EXISTS test_factory_pgtap$$, 'drop extension test_factory_pgtap');
11+
SELECT lives_ok($$DROP EXTENSION IF EXISTS test_factory$$, 'drop extension test_factory');
12+
13+
SELECT hasnt_extension( 'test_factory' );
14+
SELECT hasnt_extension( 'test_factory_pgtap' );
15+
16+
SELECT lives_ok($$CREATE EXTENSION test_factory_pgtap CASCADE$$, 'create extension');
17+
COMMIT;
18+
19+
SELECT has_function('tf', 'tap', array['text','text']);
20+
21+
-- Cleanup
22+
SELECT lives_ok($$DROP EXTENSION IF EXISTS test_factory_pgtap$$, 'clean-up test_factory_pgtap');
23+
SELECT lives_ok($$DROP EXTENSION IF EXISTS test_factory$$, 'clean-up test_factory');
24+
25+
/*
26+
* Arguably we should cleanup pgtap and the tap schema...
27+
*/
28+
29+
-- vi: expandtab ts=2 sw=2
30+

0 commit comments

Comments
 (0)