File: 01-force.t

package info (click to toggle)
libdbix-runsql-perl 0.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 248 kB
  • sloc: perl: 786; sql: 26; makefile: 10
file content (41 lines) | stat: -rw-r--r-- 833 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!perl -w
use strict;
use Test::More;

use DBIx::RunSQL;

my $can_run = eval {
    require DBD::SQLite;
    1
};

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";
isnt $@, '', "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";