Skip to content

Commit

Permalink
Made testing suitable for another databases too
Browse files Browse the repository at this point in the history
  • Loading branch information
vti committed Oct 26, 2011
1 parent d0a02bc commit 91c95d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
8 changes: 4 additions & 4 deletions t/lib/TestDB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ sub dbh {

my @args = ();

if ($ENV{TEST_MYSQL}) {
my @options = split(',', $ENV{TEST_MYSQL});
push @args, 'dbi:mysql:' . shift @options, @options;
if ($ENV{TEST_DSN}) {
my @options = split(',', $ENV{TEST_DSN});
push @args, 'dbi:' . (shift @options) . ':', @options;
}
else {
push @args, 'dbi:SQLite:' . ':memory:';
Expand All @@ -27,7 +27,7 @@ sub dbh {
my $dbh = DBI->connect(@args);
die $DBI::errorstr unless $dbh;

unless ($ENV{TEST_MYSQL}) {
unless ($ENV{TEST_DSN}) {
$dbh->do("PRAGMA default_synchronous = OFF");
$dbh->do("PRAGMA temp_store = MEMORY");
}
Expand Down
15 changes: 1 addition & 14 deletions t/lib/TestEnv.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,7 @@ sub setup {
my $driver = $dbh->{'Driver'}->{'Name'};
return unless $driver eq 'SQLite';

my $filename;
if ($driver =~ m/SQLite/) {
$filename = 'sqlite';
}
elsif ($driver =~ m/mysql/) {
$filename = 'mysql';
}
else {
die "Unknown driver $driver";
}

my $fullpath = "$FindBin::Bin/schema/$filename.sql";
$fullpath = "$FindBin::Bin/../schema/$filename.sql"
unless -e $fullpath;
my $fullpath = "$FindBin::Bin/schema/$driver.sql";

open(my $file, "<$fullpath") or die "Can't open $fullpath: $!";

Expand Down
File renamed without changes.

0 comments on commit 91c95d2

Please sign in to comment.