1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-08 06:38:12 -04:00
DBD-SQLite-SQLcipher/t/lib/Test.pm
Kenichi Ishigaki 5cbeb50890 DBD-SQLite: switched to use :memory: for most of the tests
Speaking more specifically, for the tests that don't require reconnection. It seems this makes it easier to find memory leaks by DBD::SQLite itself.
2009-07-02 10:00:51 +00:00

47 lines
916 B
Perl

package t::lib::Test;
# Support code for DBD::SQLite tests
use strict;
use Exporter ();
use File::Spec ();
use Test::More ();
use vars qw{$VERSION @ISA @EXPORT};
BEGIN {
$VERSION = '1.26_01';
@ISA = 'Exporter';
@EXPORT = 'connect_ok';
# Allow tests to load modules bundled in /inc
unshift @INC, 'inc';
}
# Always load the DBI module
use DBI ();
# Delete temporary files
sub clean {
unlink( 'foo' );
unlink( 'foo-journal' );
}
# Clean up temporary test files both at the beginning and end of the
# test script.
BEGIN { clean() }
END { clean() }
# A simplified connect function for the most common case
sub connect_ok {
my $attr = { @_ };
my $dbfile = delete $attr->{dbfile} || ':memory:';
my @params = ( "dbi:SQLite:dbname=$dbfile", '', '' );
if ( %$attr ) {
push @params, $attr;
}
my $dbh = DBI->connect( @params );
Test::More::isa_ok( $dbh, 'DBI::db' );
return $dbh;
}
1;