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
19 lines
585 B
PL/PgSQL
19 lines
585 B
PL/PgSQL
-- wtt_load tests the wtt_load test helper function.
|
|
begin;
|
|
select plan(6);
|
|
|
|
-- invalid or missing args
|
|
select throws_ok($$select wtt_load('unknown', 'iam')$$);
|
|
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('widgets', 'auth', 'iam')$$);
|
|
|
|
-- missing a dependancy, auth depends on iam
|
|
select throws_ok($$select wtt_load('widgets', 'auth')$$);
|
|
|
|
select * from finish();
|
|
rollback;
|