diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-26 11:48:55 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-26 13:42:35 +0100 |
commit | d6469b885f86afbd307066a928a4007a579af7f6 (patch) | |
tree | a635569d80cb6e6adbcf0f1014641d95d4228739 /perllib/FixMyStreet/TestAppProve.pm | |
parent | 96d6d115c68d5e0a4b23612aa630c3e0de98daa5 (diff) |
Fix issue with test database removal.
Upgrade Test::PostgreSQL, which fixes a bug delaying the end
of test running, and introduces a nicer setup mechanism.
Diffstat (limited to 'perllib/FixMyStreet/TestAppProve.pm')
-rw-r--r-- | perllib/FixMyStreet/TestAppProve.pm | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/TestAppProve.pm b/perllib/FixMyStreet/TestAppProve.pm index 049f7da6c..4a55d587b 100644 --- a/perllib/FixMyStreet/TestAppProve.pm +++ b/perllib/FixMyStreet/TestAppProve.pm @@ -37,20 +37,16 @@ my $pg; sub spin_up_database { warn "Spinning up a Pg cluster/database...\n"; - $pg = Test::PostgreSQL->new(); + $pg = Test::PostgreSQL->new( + seed_scripts => [ + 'db/schema.sql', + 'db/fixture.sql', + 'db/generate_secret.sql', + ], + ); warn sprintf "# Connected to %s\n", $pg->dsn; - my $dbh = DBI->connect($pg->dsn); - - my $tmpwarn = $SIG{__WARN__}; - $SIG{__WARN__} = - sub { print STDERR @_ if $_[0] !~ m/NOTICE: CREATE TABLE/; }; - $dbh->do( path('db/schema.sql')->slurp ) or die $!; - $dbh->do( path('db/fixture.sql')->slurp ) or die $!; - $dbh->do( path('db/generate_secret.sql')->slurp ) or die $!; - $SIG{__WARN__} = $tmpwarn; - return { FMS_DB_PORT => $pg->port, FMS_DB_NAME => 'test', |