diff options
-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"); |