$self->{db} = DBI->connect(
"dbi:SQLite:dbname=$db_file",
"",
"",
{RaiseError => 1}
) or die $DBI::errstr;
####
{ # crash the connect()
my $ok = eval {
App::RPi::EnvUI::DB->new(
db_file => '/'
);
1;
};
is
$ok,
undef,
"when a DBH can't be created, we die";
like
$@,
qr/unable to open database/,
"...and the error message is sane";
}
{ # good connect()
my $db = App::RPi::EnvUI::DB->new(
testing => 1
);
is
ref $db->{db},
'DBI::db',
"dbh loaded ok";
}
####
23 50 T F unless $self->{'db'} = 'DBI'->connect("dbi:SQLite:dbname=$db_file", '', '', {'RaiseError', 1})
####
Files=19, Tests=894, 83 wallclock secs ...
Result: PASS