From: Dagfinn Ilmari Mannsåker Date: Sun, 17 Mar 2013 14:07:55 +0000 (+0000) Subject: Clean up properly after Parser::DBI::PostgreSQL tests X-Git-Tag: v0.011017~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7b1bb6588589c3f1d6e17ff1cb6af5941136720b;hp=aa068030f5b8038d5f5653b70cfcf478bf52583e;p=dbsrgits%2FSQL-Translator.git Clean up properly after Parser::DBI::PostgreSQL tests Deleting the table in END {} after having disconnected isn't going to work. Instead, take advantage of PostgreSQL's transactional DDL support, and do the tests inside a transcation that is rolled back at the end. --- diff --git a/Changes b/Changes index 840828a..1ba6d2a 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,7 @@ * Call all diff methods in list context (it can be merged later) * Fix Pg diff issue with drop constraint on primary keys * SQLite support for SET NULL, SET DEFAULT and NO ACTION in FK clauses +* Clean up properly after Parser::DBI::PostgreSQL tests # ---------------------------------------------------------- # 0.11016 2012-10-09 diff --git a/t/66-postgres-dbi-parser.t b/t/66-postgres-dbi-parser.t index 4015660..94f3260 100644 --- a/t/66-postgres-dbi-parser.t +++ b/t/66-postgres-dbi-parser.t @@ -71,6 +71,7 @@ my $sql = q[ $| = 1; +$dbh->begin_work; $dbh->do($sql); my $t = SQL::Translator->new( @@ -176,18 +177,7 @@ is( scalar @t2_constraints, 1, "One constraint on table" ); my $t2_c1 = shift @t2_constraints; is( $t2_c1->type, FOREIGN_KEY, "Constraint is a FK" ); +$dbh->rollback; $dbh->disconnect; } # end of SKIP block -END { - if ($dbh) { - for ( - 'drop table if exists sqlt_test2', - 'drop table if exists sqlt_test1', - 'drop table if exists sqlt_products_1', - ) { - local $SIG{__WARN__} = sub {}; - eval { $dbh->do($_) }; - } - } -}