Skip to content

Commit

Permalink
return ASAP on lack of SQLite
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed May 23, 2012
1 parent 64271a3 commit 1bd17a5
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions t/01-force.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ my $can_run = eval {
1
};

if ($can_run) {
plan tests => 5;
my $warn;
local $SIG{__WARN__} = sub { $warn = shift };
my $lives = eval {
my $test_dbh = DBIx::RunSQL->create(
dsn => 'dbi:SQLite:dbname=:memory:',
sql => $0,
);
1;
};
my $err = $@;
ok !$lives, "We die on invalid SQL";
isn't $@, '', "We die with some error message";
$lives = eval {
my $test_dbh = DBIx::RunSQL->create(
dsn => 'dbi:SQLite:dbname=:memory:',
sql => $0,
force => 1,
);
1;
};
$err = $@;
ok $lives, "We can force invalid SQL";
is $@, '', "We don't die with some error message";
like $warn, qr/SQL ERROR/, "We still warn about SQL errors";
} else {
if (not $can_run) {
plan skip_all => "SQLite not installed";
}

plan tests => 5;
my $warn;
local $SIG{__WARN__} = sub { $warn = shift };
my $lives = eval {
my $test_dbh = DBIx::RunSQL->create(
dsn => 'dbi:SQLite:dbname=:memory:',
sql => $0,
);
1;
};
my $err = $@;
ok !$lives, "We die on invalid SQL";
isn't $@, '', "We die with some error message";
$lives = eval {
my $test_dbh = DBIx::RunSQL->create(
dsn => 'dbi:SQLite:dbname=:memory:',
sql => $0,
force => 1,
);
1;
};
$err = $@;
ok $lives, "We can force invalid SQL";
is $@, '', "We don't die with some error message";
like $warn, qr/SQL ERROR/, "We still warn about SQL errors";

0 comments on commit 1bd17a5

Please sign in to comment.