Skip to content

Commit

Permalink
[test] Adjust periods tests to sql_saga
Browse files Browse the repository at this point in the history
Mainly propagate renames and remove system time related tests.
Add test for issue 27 about foreign key consistency.
  • Loading branch information
jhf committed Oct 31, 2023
1 parent 56527e7 commit 63a9e99
Show file tree
Hide file tree
Showing 29 changed files with 708 additions and 2,180 deletions.
18 changes: 8 additions & 10 deletions expected/01_install.out
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/* Once support for 9.5 has passed, use CASCADE */
CREATE EXTENSION IF NOT EXISTS btree_gist;
/* Once support for 9.6 has passed, just create the extension */
CREATE EXTENSION periods VERSION '1.2';
CREATE EXTENSION sql_saga VERSION '1.0' CASCADE;
NOTICE: installing required extension "btree_gist"
SELECT extversion
FROM pg_extension
WHERE extname = 'periods';
WHERE extname = 'sql_saga';
extversion
------------
1.2
1.0
(1 row)

DROP ROLE periods_unprivileged_user;
ERROR: role "periods_unprivileged_user" does not exist
CREATE ROLE periods_unprivileged_user;
/* Make tests work on PG 15 */
DROP ROLE IF EXISTS sql_saga_unprivileged_user;
NOTICE: role "sql_saga_unprivileged_user" does not exist, skipping
CREATE ROLE sql_saga_unprivileged_user;
/* Make tests work on PG 15+ */
GRANT CREATE ON SCHEMA public TO PUBLIC;
87 changes: 40 additions & 47 deletions expected/02_periods.out
Original file line number Diff line number Diff line change
@@ -1,75 +1,68 @@
SELECT setting::integer < 130000 AS pre_13
FROM pg_settings WHERE name = 'server_version_num';
pre_13
--------
f
(1 row)

/* Run tests as unprivileged user */
SET ROLE TO periods_unprivileged_user;
SET ROLE TO sql_saga_unprivileged_user;
/* Basic period definitions with dates */
CREATE TABLE basic (val text, s date, e date);
TABLE periods.periods;
table_name | period_name | start_column_name | end_column_name | range_type | bounds_check_constraint
------------+-------------+-------------------+-----------------+------------+-------------------------
TABLE sql_saga.era;
table_name | era_name | start_column_name | end_column_name | range_type | bounds_check_constraint | audit_table_name
------------+----------+-------------------+-----------------+------------+-------------------------+------------------
(0 rows)

SELECT periods.add_period('basic', 'bp', 's', 'e');
add_period
------------
SELECT sql_saga.add_era('basic', 's', 'e', 'bp');
add_era
---------
t
(1 row)

TABLE periods.periods;
table_name | period_name | start_column_name | end_column_name | range_type | bounds_check_constraint
------------+-------------+-------------------+-----------------+------------+-------------------------
basic | bp | s | e | daterange | basic_bp_check
TABLE sql_saga.era;
table_name | era_name | start_column_name | end_column_name | range_type | bounds_check_constraint | audit_table_name
------------+----------+-------------------+-----------------+------------+-------------------------+------------------
basic | bp | s | e | daterange | basic_bp_check |
(1 row)

SELECT periods.drop_period('basic', 'bp');
drop_period
-------------
SELECT sql_saga.drop_era('basic', 'bp');
drop_era
----------
t
(1 row)

TABLE periods.periods;
table_name | period_name | start_column_name | end_column_name | range_type | bounds_check_constraint
------------+-------------+-------------------+-----------------+------------+-------------------------
TABLE sql_saga.era;
table_name | era_name | start_column_name | end_column_name | range_type | bounds_check_constraint | audit_table_name
------------+----------+-------------------+-----------------+------------+-------------------------+------------------
(0 rows)

SELECT periods.add_period('basic', 'bp', 's', 'e', bounds_check_constraint => 'c');
add_period
------------
SELECT sql_saga.add_era('basic', 's', 'e', 'bp', bounds_check_constraint => 'c');
add_era
---------
t
(1 row)

TABLE periods.periods;
table_name | period_name | start_column_name | end_column_name | range_type | bounds_check_constraint
------------+-------------+-------------------+-----------------+------------+-------------------------
basic | bp | s | e | daterange | c
TABLE sql_saga.era;
table_name | era_name | start_column_name | end_column_name | range_type | bounds_check_constraint | audit_table_name
------------+----------+-------------------+-----------------+------------+-------------------------+------------------
basic | bp | s | e | daterange | c |
(1 row)

SELECT periods.drop_period('basic', 'bp', purge => true);
drop_period
-------------
SELECT sql_saga.drop_era('basic', 'bp', purge => true);
drop_era
----------
t
(1 row)

TABLE periods.periods;
table_name | period_name | start_column_name | end_column_name | range_type | bounds_check_constraint
------------+-------------+-------------------+-----------------+------------+-------------------------
TABLE sql_saga.era;
table_name | era_name | start_column_name | end_column_name | range_type | bounds_check_constraint | audit_table_name
------------+----------+-------------------+-----------------+------------+-------------------------+------------------
(0 rows)

SELECT periods.add_period('basic', 'bp', 's', 'e');
add_period
------------
SELECT sql_saga.add_era('basic', 's', 'e', 'bp');
add_era
---------
t
(1 row)

TABLE periods.periods;
table_name | period_name | start_column_name | end_column_name | range_type | bounds_check_constraint
------------+-------------+-------------------+-----------------+------------+-------------------------
basic | bp | s | e | daterange | basic_bp_check
TABLE sql_saga.era;
table_name | era_name | start_column_name | end_column_name | range_type | bounds_check_constraint | audit_table_name
------------+----------+-------------------+-----------------+------------+-------------------------+------------------
basic | bp | s | e | daterange | basic_bp_check |
(1 row)

/* Test constraints */
Expand All @@ -94,8 +87,8 @@ TABLE basic;

/* Test dropping the whole thing */
DROP TABLE basic;
TABLE periods.periods;
table_name | period_name | start_column_name | end_column_name | range_type | bounds_check_constraint
------------+-------------+-------------------+-----------------+------------+-------------------------
TABLE sql_saga.era;
table_name | era_name | start_column_name | end_column_name | range_type | bounds_check_constraint | audit_table_name
------------+----------+-------------------+-----------------+------------+-------------------------+------------------
(0 rows)

Loading

0 comments on commit 63a9e99

Please sign in to comment.