Mercurial > gemma
changeset 196:b67208d82543
Make test output more comprehensive
Running all tests in one transaction ensures the final output tells
about any failing test, not just in the last transaction (i.e.
test script).
The price is that no traces of the tests are left in the database
because we have to rollback in order to have no left-over test roles
in the cluster.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 20 Jul 2018 18:31:45 +0200 |
parents | 5dc8e734487a |
children | e85413e5befa |
files | schema/auth_tests.sql schema/manage_users_tests.sql schema/run_tests.sh |
diffstat | 3 files changed, 9 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/schema/auth_tests.sql Fri Jul 20 17:28:16 2018 +0200 +++ b/schema/auth_tests.sql Fri Jul 20 18:31:45 2018 +0200 @@ -1,7 +1,6 @@ -- -- pgTAP test script for privileges and RLS policies -- -SELECT plan(16); -- Give number of tests that have to be run -- -- Run tests as unprivileged user @@ -90,8 +89,3 @@ SELECT is_empty('DELETE FROM users.templates WHERE template_name = ''RO'' RETURNING *', 'Waterway admin cannot delete templates for other country'); - --- --- finish tests --- -SELECT * FROM finish();
--- a/schema/manage_users_tests.sql Fri Jul 20 17:28:16 2018 +0200 +++ b/schema/manage_users_tests.sql Fri Jul 20 18:31:45 2018 +0200 @@ -1,8 +1,6 @@ -BEGIN; -- -- pgTAP test script for user management functions -- -SELECT plan(6); -- Give number of tests that have to be run SET search_path TO public, gemma, gemma_waterway, gemma_fairway; @@ -51,12 +49,3 @@ $$, 23505, NULL, 'No duplicate e-mail adress is allowed'); - --- --- finish tests --- -SELECT * FROM finish(); - --- Rollback because we don't want test roles to stay in the cluster, which --- would make tests not repeatable -ROLLBACK;
--- a/schema/run_tests.sh Fri Jul 20 17:28:16 2018 +0200 +++ b/schema/run_tests.sh Fri Jul 20 18:31:45 2018 +0200 @@ -9,7 +9,12 @@ -f auth.sql \ -f manage_users.sql -psql -qv ON_ERROR_STOP= -f tap_tests_data.sql -d gemma_test - -psql -Xf auth_tests.sql -d gemma_test -psql -Xf manage_users_tests.sql -d gemma_test +# Add test data, run tests and ROLLBACK to prevent test roles to stay +# in cluster, which would prevent tests from being repeatable +psql -qXv ON_ERROR_STOP= -v AUTOCOMMIT=off -d gemma_test \ + -f tap_tests_data.sql \ + -c 'SELECT plan(22)' \ + -f auth_tests.sql \ + -f manage_users_tests.sql \ + -c 'SELECT * FROM finish()' \ + -c 'ROLLBACK'