From 9820080ca9470ffd1992430fc2842c2779839053 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Sat, 1 Dec 2007 03:17:44 +0000 Subject: Add a MySQL method to check the tables remaining after a drop. --- perl/t/schema.t | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'perl/t') diff --git a/perl/t/schema.t b/perl/t/schema.t index e52a70d..1068048 100755 --- a/perl/t/schema.t +++ b/perl/t/schema.t @@ -40,14 +40,31 @@ is ($@, '', "create() doesn't die"); # Test dropping the database. eval { $schema->drop ($dbh) }; is ($@, '', "drop() doesn't die"); -my $sql = "select name from sqlite_master where type = 'table'"; -my $sth = $dbh->prepare ($sql); -$sth->execute; -my ($table, @tables); -while (defined ($table = $sth->fetchrow_array)) { - push (@tables, $table) unless $table =~ /^sqlite_/; + +# Make sure all the tables are gone. +SKIP: { + if (lc ($Wallet::Config::DB_DRIVER) eq 'sqlite') { + my $sql = "select name from sqlite_master where type = 'table'"; + my $sth = $dbh->prepare ($sql); + $sth->execute; + my ($table, @tables); + while (defined ($table = $sth->fetchrow_array)) { + push (@tables, $table) unless $table =~ /^sqlite_/; + } + is ("@tables", '', ' and there are no tables in the database'); + } elsif (lc ($Wallet::Config::DB_DRIVER) eq 'mysql') { + my $sql = "show tables"; + my $sth = $dbh->prepare ($sql); + $sth->execute; + my ($table, @tables); + while (defined ($table = $sth->fetchrow_array)) { + push (@tables, $table); + } + is ("@tables", '', ' and there are no tables in the database'); + } else { + skip 1; + } } -is ("@tables", '', ' and there are no tables in the database'); eval { $schema->create ($dbh) }; is ($@, '', ' and we can run create again'); -- cgit v1.2.3