diff options
author | Russ Allbery <rra@stanford.edu> | 2007-12-01 00:42:46 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2007-12-01 00:42:46 +0000 |
commit | c9948c8f68b11a1e897afe9c9f2dd2fcb6934f8d (patch) | |
tree | f15323beb5ceac6a2b81df8634f5f9f23ad239c8 /perl/t/schema.t | |
parent | 1e13c0c60c96dd1719e7c4c3931b4196c2b5bc61 (diff) |
The wallet backend test suite now supports using a database other than
SQLite for testing.
Also start a new Util.pm module for the test suite and move the contents
sub into that module. More to follow.
Diffstat (limited to 'perl/t/schema.t')
-rwxr-xr-x | perl/t/schema.t | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/perl/t/schema.t b/perl/t/schema.t index 9e2d84f..566d67d 100755 --- a/perl/t/schema.t +++ b/perl/t/schema.t @@ -8,11 +8,14 @@ # # See LICENSE for licensing terms. -use Test::More tests => 8; +use Test::More tests => 10; use DBI; use Wallet::Schema; +use lib 't/lib'; +use Util; + my $schema = Wallet::Schema->new; ok (defined $schema, 'Wallet::Schema creation'); ok ($schema->isa ('Wallet::Schema'), ' and class verification'); @@ -21,7 +24,6 @@ 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. -unlink 'wallet-db'; my $dbh = DBI->connect ("DBI:SQLite:wallet-db"); if (not defined $dbh) { die "cannot create database wallet-db: $DBI::errstr\n"; @@ -48,3 +50,17 @@ 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}"; +$dbh = DBI->connect ($connect); +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"); |