Mercurial > gemma
annotate schema/run_tests.sh @ 234:55dce2f649bc
Allow using the same email-address for multiple users
This can be useful at least in testing scenarios, where one
person wants to have multiple accounts with different roles
and there is no other reason to enforce uniqueness.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 26 Jul 2018 15:10:22 +0200 |
parents | 4859aa6c96be |
children | 299568ad3c37 |
rev | line source |
---|---|
172
a422471db08a
Automate running DB-tests with an extra database
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
1 #!/bin/sh -e |
a422471db08a
Automate running DB-tests with an extra database
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
2 |
a422471db08a
Automate running DB-tests with an extra database
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
3 dropdb --if-exists gemma_test |
a422471db08a
Automate running DB-tests with an extra database
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
4 createdb gemma_test |
183
f3a09fc9c1eb
Prepare for having more than one database test script
Tom Gottfried <tom@intevation.de>
parents:
172
diff
changeset
|
5 psql -qv ON_ERROR_STOP= -c 'CREATE EXTENSION pgtap' -d gemma_test |
172
a422471db08a
Automate running DB-tests with an extra database
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
6 |
185
a9d9c2b1d08c
Add database function to create role and user profile
Tom Gottfried <tom@intevation.de>
parents:
183
diff
changeset
|
7 psql -qv ON_ERROR_STOP= -d gemma_test \ |
a9d9c2b1d08c
Add database function to create role and user profile
Tom Gottfried <tom@intevation.de>
parents:
183
diff
changeset
|
8 -f gemma.sql \ |
a9d9c2b1d08c
Add database function to create role and user profile
Tom Gottfried <tom@intevation.de>
parents:
183
diff
changeset
|
9 -f auth.sql \ |
a9d9c2b1d08c
Add database function to create role and user profile
Tom Gottfried <tom@intevation.de>
parents:
183
diff
changeset
|
10 -f manage_users.sql |
172
a422471db08a
Automate running DB-tests with an extra database
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
11 |
224
57dfab80973c
By convention, prefix all test users with 'test'
Tom Gottfried <tom@intevation.de>
parents:
223
diff
changeset
|
12 # Collect test roles to be dropped |
57dfab80973c
By convention, prefix all test users with 'test'
Tom Gottfried <tom@intevation.de>
parents:
223
diff
changeset
|
13 # Concatenate with dummy role to prevent syntax error if there is no test role |
57dfab80973c
By convention, prefix all test users with 'test'
Tom Gottfried <tom@intevation.de>
parents:
223
diff
changeset
|
14 TEST_ROLES=$(psql -qtc \ |
57dfab80973c
By convention, prefix all test users with 'test'
Tom Gottfried <tom@intevation.de>
parents:
223
diff
changeset
|
15 "SELECT concat_ws(',', 'test', string_agg(rolname, ',')) FROM pg_roles |
57dfab80973c
By convention, prefix all test users with 'test'
Tom Gottfried <tom@intevation.de>
parents:
223
diff
changeset
|
16 WHERE rolname LIKE 'test%'") |
57dfab80973c
By convention, prefix all test users with 'test'
Tom Gottfried <tom@intevation.de>
parents:
223
diff
changeset
|
17 |
57dfab80973c
By convention, prefix all test users with 'test'
Tom Gottfried <tom@intevation.de>
parents:
223
diff
changeset
|
18 # Drop test roles, add test data and run tests |
222
cfde876fbaf9
Try to DROP ROLEs before creating them and keep test results
Tom Gottfried <tom@intevation.de>
parents:
207
diff
changeset
|
19 psql -qXv ON_ERROR_STOP= -v -d gemma_test \ |
224
57dfab80973c
By convention, prefix all test users with 'test'
Tom Gottfried <tom@intevation.de>
parents:
223
diff
changeset
|
20 -c "DROP ROLE IF EXISTS $TEST_ROLES" \ |
196
b67208d82543
Make test output more comprehensive
Tom Gottfried <tom@intevation.de>
parents:
185
diff
changeset
|
21 -f tap_tests_data.sql \ |
234
55dce2f649bc
Allow using the same email-address for multiple users
Tom Gottfried <tom@intevation.de>
parents:
232
diff
changeset
|
22 -c 'SELECT plan(35)' \ |
196
b67208d82543
Make test output more comprehensive
Tom Gottfried <tom@intevation.de>
parents:
185
diff
changeset
|
23 -f auth_tests.sql \ |
b67208d82543
Make test output more comprehensive
Tom Gottfried <tom@intevation.de>
parents:
185
diff
changeset
|
24 -f manage_users_tests.sql \ |
222
cfde876fbaf9
Try to DROP ROLEs before creating them and keep test results
Tom Gottfried <tom@intevation.de>
parents:
207
diff
changeset
|
25 -c 'SELECT * FROM finish()' |