diff options
author | Russ Allbery <rra@stanford.edu> | 2007-08-31 06:55:25 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2007-08-31 06:55:25 +0000 |
commit | 6ff0bf762b1f5fde630bc65353c4058c4ccc9fcb (patch) | |
tree | 1e2cec73a56c23efa6174749e0cfe61aa29a6c72 /perl/t | |
parent | cb6bb8bda430f3da1bea598e9bcdc4d8504902a8 (diff) |
Check handling of invalid database configuration and failure to connect
to the database.
Diffstat (limited to 'perl/t')
-rwxr-xr-x | perl/t/server.t | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/perl/t/server.t b/perl/t/server.t index 916e5bd..bca035e 100755 --- a/perl/t/server.t +++ b/perl/t/server.t @@ -3,7 +3,7 @@ # # t/server.t -- Tests for the wallet server API. -use Test::More tests => 198; +use Test::More tests => 201; use Wallet::Config; use Wallet::Server; @@ -436,5 +436,20 @@ is ($server->store ('base', 'service/both', 'stuff'), undef, ' or store it'); is ($server->error, 'cannot find base:service/both', ' because it is gone'); +# Now test handling of some configuration errors. +undef $Wallet::Config::DB_DRIVER; +$server = eval { Wallet::Server->new ($user2, $host) }; +is ($@, "database connection information not configured\n", + 'Fail if DB_DRIVER is not set'); +$Wallet::Config::DB_DRIVER = 'SQLite'; +undef $Wallet::Config::DB_INFO; +$server = eval { Wallet::Server->new ($user2, $host) }; +is ($@, "database connection information not configured\n", + ' or if DB_INFO is not set'); +$Wallet::Config::DB_INFO = 't'; +$server = eval { Wallet::Server->new ($user2, $host) }; +like ($@, qr/^cannot connect to database: /, + ' or if the database connection fails'); + # Clean up. unlink 'wallet-db'; |