# HG changeset patch # User Tom Gottfried # Date 1532104305 -7200 # Node ID b67208d82543f90c55cb6c73b3ad427bca3b1249 # Parent 5dc8e734487a10aab52915dfe69d3539a6dc6549 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. diff -r 5dc8e734487a -r b67208d82543 schema/auth_tests.sql --- 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(); diff -r 5dc8e734487a -r b67208d82543 schema/manage_users_tests.sql --- 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; diff -r 5dc8e734487a -r b67208d82543 schema/run_tests.sh --- 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'