Mercurial > gemma
view schema/manage_users_tests.sql @ 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 | 88d21c29cf04 |
line wrap: on
line source
-- -- pgTAP test script for user management functions -- SET search_path TO public, gemma, gemma_waterway, gemma_fairway; SET SESSION AUTHORIZATION waterway_admin; SELECT throws_ok($$ SELECT sys_admin.create_user( 'waterway_user', 'test0', 'secret', 'AT', NULL, 'test0') $$, 42501, NULL, 'Less privileged user cannot call function in schema sys_admin'); SET SESSION AUTHORIZATION sys_admin; SELECT lives_ok($$ SELECT sys_admin.create_user( 'waterway_user', 'test1', 'secret', 'AT', NULL, 'test1') $$, 'New waterway user can be added'); SELECT throws_ok($$ SELECT sys_admin.create_user( 'invalid', 'test2', 'secret', 'AT', NULL, 'test2') $$, 42704, NULL, 'Valid role name has to be provided'); SELECT throws_ok($$ SELECT sys_admin.create_user( 'waterway_user', NULL, 'secret', 'AT', NULL, 'test3') $$, 23502, NULL, 'username is mandatory'); -- Though other arguments are mandatory, too, there are no explicit tests SELECT throws_ok($$ SELECT sys_admin.create_user( 'waterway_user', 'waterway_user', 'secret', 'AT', NULL, 'test4') $$, 23505, NULL, 'No duplicate user name is allowed'); SELECT throws_ok($$ SELECT sys_admin.create_user( 'waterway_user', 'test2', 'secret', 'AT', NULL, 'xxx') $$, 23505, NULL, 'No duplicate e-mail adress is allowed');