diff options
| author | Russ Allbery <rra@stanford.edu> | 2007-12-01 03:17:44 +0000 | 
|---|---|---|
| committer | Russ Allbery <rra@stanford.edu> | 2007-12-01 03:17:44 +0000 | 
| commit | 9820080ca9470ffd1992430fc2842c2779839053 (patch) | |
| tree | ff54f689f3685091dadc22c3bd73389ba85f59a8 | |
| parent | 9a9a18d364c454e42e83dcdeedfd30eb9e3e91bd (diff) | |
Add a MySQL method to check the tables remaining after a drop.
| -rwxr-xr-x | perl/t/schema.t | 31 | 
1 files changed, 24 insertions, 7 deletions
| 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'); | 
