1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-08 14:48:32 -04:00

DBD-SQLite: added "cleanup" blocks to the tests to allow each test run clean and separately (note: three tests are currently broken -- fixes follow soon)

This commit is contained in:
Kenichi Ishigaki 2009-04-02 11:23:35 +00:00
parent fbedeb1a93
commit 3330bd7468
27 changed files with 52 additions and 6 deletions

View file

@ -13,3 +13,4 @@ ok($dbh->func('busy_timeout'), 5000);
print "# sqlite_busy_timeout=", $dbh->func('busy_timeout'), "\n"; print "# sqlite_busy_timeout=", $dbh->func('busy_timeout'), "\n";
$dbh->disconnect; $dbh->disconnect;
END { unlink 'foo' }

View file

@ -3,7 +3,6 @@ use strict;
use Test; use Test;
BEGIN { plan tests => 4 } BEGIN { plan tests => 4 }
use DBI; use DBI;
unlink("foo");
my $dbh = DBI->connect("dbi:SQLite:dbname=foo", "", ""); my $dbh = DBI->connect("dbi:SQLite:dbname=foo", "", "");
ok($dbh); ok($dbh);
$dbh->{AutoCommit} = 1; $dbh->{AutoCommit} = 1;
@ -16,3 +15,5 @@ print("# ", join(', ', @$names), "\n");
ok($names->[0] eq "f1"); # make sure the "f." is removed ok($names->[0] eq "f1"); # make sure the "f." is removed
undef $sth; undef $sth;
$dbh->disconnect; $dbh->disconnect;
END { unlink 'foo' }

View file

@ -24,3 +24,5 @@ ok($dbh->do("delete from f where f1='test'"), 3);
$sth->finish; $sth->finish;
undef $sth; undef $sth;
$dbh->disconnect; $dbh->disconnect;
END { unlink 'foo' }

View file

@ -53,3 +53,5 @@ $sth->finish;
undef $sth; undef $sth;
$dbh->do("delete from f where f1='test'"); $dbh->do("delete from f where f1='test'");
$dbh->disconnect; $dbh->disconnect;
END { unlink 'foo' }

View file

@ -36,3 +36,5 @@ while(my $raD = $sth->fetchrow_arrayref()) {
} }
undef $sth; undef $sth;
$dbh->disconnect; $dbh->disconnect;
END { unlink 'foo' }

View file

@ -19,3 +19,5 @@ eval {
$db->do('insert into testerror values (1, 5)'); $db->do('insert into testerror values (1, 5)');
}; };
ok($@); ok($@);
END { unlink 'foo' }

View file

@ -5,7 +5,6 @@ use Test;
BEGIN { plan tests => 8 } BEGIN { plan tests => 8 }
use DBI; use DBI;
unlink('foo', 'foo-journal');
my $db = DBI->connect('dbi:SQLite:foo', '', '', my $db = DBI->connect('dbi:SQLite:foo', '', '',
{ {
RaiseError => 1, RaiseError => 1,
@ -74,3 +73,5 @@ if (!defined($pid)) {
$db->commit; $db->commit;
wait; wait;
} }
END { unlink('foo', 'foo-journal') }

View file

@ -120,3 +120,5 @@ $result = $dbh->selectrow_arrayref( "SELECT noop(1.0625)" );
is_deeply( $result, [ 1.0625 ], "SELECT noop(1.0625)" ); is_deeply( $result, [ 1.0625 ], "SELECT noop(1.0625)" );
$dbh->disconnect; $dbh->disconnect;
END { unlink 'foo' }

View file

@ -127,3 +127,5 @@ $dbh->func( "fail_undef", -1, $aggr, 'create_aggregate' );
$result = $dbh->selectrow_arrayref( "SELECT fail_undef() FROM aggr_test" ); $result = $dbh->selectrow_arrayref( "SELECT fail_undef() FROM aggr_test" );
# ok( !$result && $DBI::errstr =~ /new\(\) should return a blessed reference/ ); # ok( !$result && $DBI::errstr =~ /new\(\) should return a blessed reference/ );
ok( !defined $result->[0] && $last_warn =~ /new\(\) should return a blessed reference/ ); ok( !defined $result->[0] && $last_warn =~ /new\(\) should return a blessed reference/ );
END { unlink 'foo' }

View file

@ -81,3 +81,5 @@ exit 0;
# Hate -w :-) # Hate -w :-)
$test_dsn = $test_user = $test_password = $DBI::errstr; $test_dsn = $test_user = $test_password = $DBI::errstr;
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -133,4 +133,6 @@ Test($lengths->[0]->[0] == $lengths->[0]->[1],
"Database actually understands char set") or "Database actually understands char set") or
warn "($lengths->[0]->[0] != $lengths->[0]->[1])"; warn "($lengths->[0]->[0] != $lengths->[0]->[1])";
END { $dbh->do("DROP TABLE $table"); } END { $dbh->do("DROP TABLE $table"); $dbh->disconnect; }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -96,3 +96,5 @@ is_deeply(\@sorted, $db_sorted, "collate no_accents (@sorted // @$db_sorted)");
$dbh->disconnect; $dbh->disconnect;
END { unlink 'foo' }

View file

@ -42,3 +42,5 @@ $result = $dbh->do( "SELECT * from progress_test ORDER BY foo DESC " );
ok(!$n_callback); ok(!$n_callback);
$dbh->disconnect; $dbh->disconnect;
END { unlink 'foo' }

View file

@ -80,3 +80,5 @@ while (Testing()) {
Test($state or $dbh->disconnect()) Test($state or $dbh->disconnect())
or DbiError($dbh->err, $dbh->errstr); or DbiError($dbh->err, $dbh->errstr);
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -148,3 +148,4 @@ while (Testing()) {
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -198,3 +198,5 @@ while (Testing()) {
Test($state or $dbh->do("DROP TABLE $table")) Test($state or $dbh->do("DROP TABLE $table"))
or DbiError($dbh->err, $dbh->errstr); or DbiError($dbh->err, $dbh->errstr);
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -175,3 +175,5 @@ while (Testing()) {
or DbiError($dbh->err, $dbh->errstr); or DbiError($dbh->err, $dbh->errstr);
} }
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -62,7 +62,7 @@ undef $sel;
$db->disconnect; $db->disconnect;
unlink('foo', 'foo-journal'); END { unlink('foo', 'foo-journal'); }
sub dumpblob { sub dumpblob {
@ -85,3 +85,4 @@ sub dumpblob {
} }
if ($ENV{SHOW_BLOBS}) { close(OUT) } if ($ENV{SHOW_BLOBS}) { close(OUT) }
} }

View file

@ -128,3 +128,5 @@ while (Testing()) {
$cursor->{'NUM_OF_FIELDS'}); $cursor->{'NUM_OF_FIELDS'});
Test($state or (undef $cursor) or 1); Test($state or (undef $cursor) or 1);
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -105,3 +105,5 @@ while (Testing()) {
or DbiError($dbh->err, $dbh->errstr); or DbiError($dbh->err, $dbh->errstr);
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -154,3 +154,5 @@ while (Testing()) {
or DbiError($dbh->err, $dbh->errstr); or DbiError($dbh->err, $dbh->errstr);
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -133,3 +133,5 @@ while (Testing()) {
or DbiError($dbh->err, $dbh->errstr); or DbiError($dbh->err, $dbh->errstr);
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -146,5 +146,4 @@ while (Testing()) {
or ErrMsgF("Cannot disconnect: %s.\n", $dbh->errmsg); or ErrMsgF("Cannot disconnect: %s.\n", $dbh->errmsg);
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -222,3 +222,5 @@ while (Testing()) {
or ErrMsgF("Cannot DROP test table $table: %s.\n", or ErrMsgF("Cannot DROP test table $table: %s.\n",
$dbh->errstr); $dbh->errstr);
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -51,3 +51,5 @@ ok($types->[1] eq 'char(1)');
ok $dbh->do("create table meta5 ( f1 integer PRIMARY KEY )"); ok $dbh->do("create table meta5 ( f1 integer PRIMARY KEY )");
@pk = $dbh->primary_key(undef, undef, 'meta5'); @pk = $dbh->primary_key(undef, undef, 'meta5');
ok($pk[0] eq 'f1'); ok($pk[0] eq 'f1');
END { unlink 'foo' }

View file

@ -94,3 +94,5 @@ while (Testing()) {
Test($state or $dbh->disconnect()) Test($state or $dbh->disconnect())
or DbiError($dbh->err, $dbh->errstr); or DbiError($dbh->err, $dbh->errstr);
} }
END { unlink 'output/foo'; rmdir 'output' }

View file

@ -354,3 +354,5 @@ while (Testing()) {
or ErrMsg("disconnect failed: $dbh->errstr.\n"); or ErrMsg("disconnect failed: $dbh->errstr.\n");
} }
} }
END { unlink 'output/foo'; rmdir 'output' }