summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xperl/t/server.t17
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';