db: Refactor test setup for pre-populated data
Now when initializing the test database for sql tests, it will load the colors persona data into the database. This will provide a data set that tests can use without needing to call `wtt_load`. The main motivation is to allow for a separation of setup and test execution that requires crossing a transaction boundary. The pgTap tests are required to exectue as a single transaction, so that the rollback can reset the state, and each test can be isolated. However, can cause issues with some test senarios, particuarly with the use of some times releated functions like `current_timestamp` and `now` which return the time that the current transaction started. This creates an issue if a test relies on some setup that sets a time via `now`, then an update that expects a new time via `now`. See: https://www.postgresql.org/docs/13/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT
This commit is contained in:
6 files changed
+196
-246
No files matched your search
@@ -4,15 +4,15 @@ begin;
|
||||
|
||||
-- invalid or missing args
|
||||
select throws_ok($$select wtt_load('unknown', 'iam')$$);
|
||||
select throws_ok($$select wtt_load('colors', 'unknown')$$);
|
||||
select throws_ok($$select wtt_load('colors')$$);
|
||||
select throws_ok($$select wtt_load('widgets', 'unknown')$$);
|
||||
select throws_ok($$select wtt_load('widgets')$$);
|
||||
select throws_ok($$select wtt_load()$$);
|
||||
|
||||
-- incorrect order since auth depends on iam
|
||||
select throws_ok($$select wtt_load('colors', 'auth', 'iam')$$);
|
||||
select throws_ok($$select wtt_load('widgets', 'auth', 'iam')$$);
|
||||
|
||||
-- missing a dependancy, auth depends on iam
|
||||
select throws_ok($$select wtt_load('colors', 'auth')$$);
|
||||
select throws_ok($$select wtt_load('widgets', 'auth')$$);
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
Reference in new issue
Block a user