rebuild-test-database: Clean up helper functions.

We now have helpers for the two places where
we create databases.

There was already one helper in place, and
I gave it a more concrete name, to match
its actual database name in postgres.
This commit is contained in:
Steve Howell 2020-04-22 00:04:02 +00:00 committed by Tim Abbott
parent 8c2f8c8bcc
commit 29ac0f36a9
1 changed files with 13 additions and 6 deletions

View File

@ -4,7 +4,15 @@ set -x
export DJANGO_SETTINGS_MODULE=zproject.test_settings
create_template_database()
create_zulip_test()
{
psql -v ON_ERROR_STOP=1 -h localhost postgres zulip_test <<EOF
DROP DATABASE IF EXISTS zulip_test;
CREATE DATABASE zulip_test TEMPLATE zulip_test_base;
EOF
}
create_zulip_test_template()
{
psql -v ON_ERROR_STOP=1 -h localhost postgres zulip_test << EOF
DROP DATABASE IF EXISTS zulip_test_template;
@ -16,10 +24,8 @@ mkdir -p zerver/tests/fixtures
"$(dirname "$0")/../scripts/setup/terminate-psql-sessions" zulip zulip_test zulip_test_base zulip_test_template
psql -v ON_ERROR_STOP=1 -h localhost postgres zulip_test <<EOF
DROP DATABASE IF EXISTS zulip_test;
CREATE DATABASE zulip_test TEMPLATE zulip_test_base;
EOF
create_zulip_test
"$(dirname "$0")/../scripts/setup/flush-memcached"
./manage.py migrate --noinput
@ -28,6 +34,7 @@ EOF
# This next line can be simplified to "-n0" once we fix our app (and tests) with 0 messages.
./manage.py populate_db --test-suite -n30 --threads=1 \
--huddles=0 --personals=0 --percent-huddles=0 --percent-personals=0
./manage.py dumpdata \
zerver.UserProfile zerver.Stream zerver.Recipient \
zerver.Subscription zerver.Message zerver.Huddle zerver.Realm \
@ -35,4 +42,4 @@ EOF
zerver.DefaultStream > zerver/tests/fixtures/messages.json
# create pristine template database, for fast fixture restoration after tests are run.
create_template_database
create_zulip_test_template