-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
Feature RequestNew feature or requestNew feature or request
Description
Would be nice to be able to use DBI with a mocked sqlite file.
The following sample is failing on ping and does not see the file as created.
Not sure how easy it would be to fix it.
note that it seems that we can write/read to it, probably because it fall back to in memory
#!perl
use Test::More;
use Test::MockFile;
use DBI;
my $f = q[/tmp/mydb.sqlite];
unlink $f;
# Comment me to run unmocked
my $mocked = Test::MockFile->file( $f );
my $dbh = DBI->connect("dbi:SQLite:dbname=$f","","", {
AutoCommit => 1,
RaiseError => 1,
});
ok $dbh->ping, 'ping';
ok $dbh->do( <<EOS ), 'create table';
CREATE TABLE groups (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
)
EOS
my $sth = $dbh->prepare("INSERT INTO groups VALUES (?, ?)");
ok $sth->execute(1 => q[group one] );
note explain [ $dbh->selectall_array("select * from groups") ];
ok -f $f, 'sqlite file created';output
╰─> perl test.pl
not ok 1 - ping
# Failed test 'ping'
# at test.pl line 21.
ok 2 - create table
ok 3
# [
# [
# 1,
# 'group one'
# ]
# ]
not ok 4 - sqlite file created
note: consider running DBI_TRACE=2 perl test.pl
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Feature RequestNew feature or requestNew feature or request