Skip to content

Commit

Permalink
stop using Test::Exception and set RaiseError on connect
Browse files Browse the repository at this point in the history
  • Loading branch information
SysPete committed Aug 22, 2014
1 parent 4099449 commit 2fd7173
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions t/postgresql-rename-table-and-field.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ use strict;
use warnings;

use Test::More;
use Test::Exception;
use Test::SQL::Translator;
use SQL::Translator;
use SQL::Translator::Diff;

maybe_plan(12, 'DBD::Pg', 'Test::PostgreSQL');
maybe_plan(10, 'DBD::Pg', 'Test::PostgreSQL');

my ( $pgsql, $dbh , $ddl, $ret );

lives_ok { $pgsql = Test::PostgreSQL->new() } "create PostgreSQL instance";
lives_ok { $dbh = DBI->connect($pgsql->dsn) } "dbi connect";
no warnings "once";
$pgsql = Test::PostgreSQL->new() or plan skip_all => $Test::PostgreSQL::errstr;
$dbh = DBI->connect($pgsql->dsn,'','', { RaiseError => 1 }) or plan skip_all => $DBI::errstr;
use warnings "once";

my $source_ddl = <<DDL;
CREATE TABLE foo (
Expand All @@ -23,9 +24,9 @@ CREATE TABLE foo (
);
DDL

lives_ok { $ret = $dbh->do($source_ddl) } "create table";
ok( $ret = $dbh->do($source_ddl), "create table" );

lives_ok { $ret = $dbh->do(q| INSERT INTO foo (bar) VALUES ('buzz') |) } "insert data";
ok( $ret = $dbh->do(q| INSERT INTO foo (bar) VALUES ('buzz') |), "insert data" );

cmp_ok( $ret, '==', 1, "one row inserted" );

Expand Down Expand Up @@ -60,10 +61,10 @@ my @diff = SQL::Translator::Diff->new({
foreach my $line (@diff) {
$line =~ s/\n//g;
next if $line =~ /^--/;
lives_ok { $dbh->do($line) || die } "$line";
ok( $dbh->do($line), "$line" );
}

lives_ok { $ret = $dbh->selectall_arrayref(q(SELECT biff FROM fluff), { Slice => {} }) } "query DB for data";
ok ( $ret = $dbh->selectall_arrayref(q(SELECT biff FROM fluff), { Slice => {} }), "query DB for data" );

cmp_ok( scalar(@$ret), '==', 1, "Got 1 row");

Expand Down

0 comments on commit 2fd7173

Please sign in to comment.