Skip to content

Commit c11d2e9

Browse files
committed
test: conditional on test for orioledb
1 parent cbcb962 commit c11d2e9

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed
Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,64 @@
11
BEGIN;
22
CREATE EXTENSION IF NOT EXISTS pgtap;
3-
do $$
4-
begin
5-
if not exists (select 1 from pg_extension where extname = 'orioledb') then
6-
create extension if not exists orioledb;
7-
end if;
8-
end $$;
3+
4+
DO $$
5+
DECLARE
6+
extension_array text[];
7+
orioledb_available boolean;
8+
BEGIN
9+
-- Check if orioledb is available
10+
SELECT EXISTS (
11+
SELECT 1 FROM pg_available_extensions WHERE name = 'orioledb'
12+
) INTO orioledb_available;
13+
14+
-- If available, create it and add to the expected extensions list
15+
IF orioledb_available THEN
16+
CREATE EXTENSION IF NOT EXISTS orioledb;
17+
extension_array := ARRAY[
18+
'plpgsql',
19+
'pg_stat_statements',
20+
'pgsodium',
21+
'pgtap',
22+
'pg_graphql',
23+
'pgcrypto',
24+
'pgjwt',
25+
'uuid-ossp',
26+
'supabase_vault',
27+
'orioledb'
28+
];
29+
ELSE
30+
extension_array := ARRAY[
31+
'plpgsql',
32+
'pg_stat_statements',
33+
'pgsodium',
34+
'pgtap',
35+
'pg_graphql',
36+
'pgcrypto',
37+
'pgjwt',
38+
'uuid-ossp',
39+
'supabase_vault'
40+
];
41+
END IF;
42+
43+
-- Set the array as a temporary variable to use in the test
44+
PERFORM set_config('myapp.extensions', array_to_string(extension_array, ','), false);
45+
END $$;
946

1047
SELECT plan(8);
1148

12-
-- Check installed extensions
1349
SELECT extensions_are(
14-
ARRAY[
15-
'plpgsql',
16-
'pg_stat_statements',
17-
'pgsodium',
18-
'pgtap',
19-
'pg_graphql',
20-
'pgcrypto',
21-
'pgjwt',
22-
'uuid-ossp',
23-
'supabase_vault'
24-
]
50+
string_to_array(current_setting('myapp.extensions'), ',')::text[]
2551
);
2652

2753

28-
-- Check schemas exists
2954
SELECT has_schema('pg_toast');
3055
SELECT has_schema('pg_catalog');
3156
SELECT has_schema('information_schema');
3257
SELECT has_schema('public');
3358

34-
-- Check that service_role can execute certain pgsodium functions
3559
SELECT function_privs_are('pgsodium', 'crypto_aead_det_decrypt', array['bytea', 'bytea', 'uuid', 'bytea'], 'service_role', array['EXECUTE']);
3660
SELECT function_privs_are('pgsodium', 'crypto_aead_det_encrypt', array['bytea', 'bytea', 'uuid', 'bytea'], 'service_role', array['EXECUTE']);
3761
SELECT function_privs_are('pgsodium', 'crypto_aead_det_keygen', array[]::text[], 'service_role', array['EXECUTE']);
3862

39-
SELECT * from finish();
40-
ROLLBACK;
63+
SELECT * FROM finish();
64+
ROLLBACK;

0 commit comments

Comments
 (0)