diff options
author | Russ Allbery <rra@stanford.edu> | 2007-12-01 03:10:43 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2007-12-01 03:10:43 +0000 |
commit | 9a6125ef765749841a766afbdea1b96b45c40e09 (patch) | |
tree | df40dfb9ee5a78f1f98e732cda8a1e371f41d2a4 | |
parent | 0d517a8c575774387393513ca196aa27211a0b0b (diff) |
Run the full schema test with the configured database. It should work
fine with MySQL.
-rwxr-xr-x | perl/t/schema.t | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/perl/t/schema.t b/perl/t/schema.t index cf98513..e52a70d 100755 --- a/perl/t/schema.t +++ b/perl/t/schema.t @@ -8,7 +8,7 @@ # # See LICENSE for licensing terms. -use Test::More tests => 10; +use Test::More tests => 8; use DBI; use Wallet::Schema; @@ -23,10 +23,14 @@ my @sql = $schema->sql; ok (@sql > 0, 'sql() returns something'); is (scalar (@sql), 26, ' and returns the right number of statements'); -# Create a SQLite database to use for create. -my $dbh = DBI->connect ("DBI:SQLite:wallet-db"); +# Connect to a database and test create. +db_setup; +my $connect = "DBI:${Wallet::Config::DB_DRIVER}:${Wallet::Config::DB_INFO}"; +my $user = $Wallet::Config::DB_USER; +my $password = $Wallet::Config::DB_PASSWORD; +$dbh = DBI->connect ($connect, $user, $password); if (not defined $dbh) { - die "cannot create database wallet-db: $DBI::errstr\n"; + die "cannot connect to database $connect: $DBI::errstr\n"; } $dbh->{RaiseError} = 1; $dbh->{PrintError} = 0; @@ -50,19 +54,3 @@ is ($@, '', ' and we can run create again'); # Clean up. eval { $schema->drop ($dbh) }; unlink 'wallet-db'; - -# Now repeat the test against the configured database in case it's different. -db_setup; -my $connect = "DBI:${Wallet::Config::DB_DRIVER}:${Wallet::Config::DB_INFO}"; -my $user = $Wallet::Config::DB_USER; -my $password = $Wallet::Config::DB_PASSWORD; -$dbh = DBI->connect ($connect, $user, $password); -if (not defined $dbh) { - die "cannot connect to database $connect: $DBI::errstr\n"; -} -$dbh->{RaiseError} = 1; -$dbh->{PrintError} = 0; -eval { $schema->create ($dbh) }; -is ($@, '', "create() against configured database doesn't die"); -eval { $schema->drop ($dbh) }; -is ($@, '', " and drop() doesn't die"); |