summaryrefslogtreecommitdiff
path: root/perl/Wallet/Server.pm
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2007-11-30 02:04:14 +0000
committerRuss Allbery <rra@stanford.edu>2007-11-30 02:04:14 +0000
commit1e13c0c60c96dd1719e7c4c3931b4196c2b5bc61 (patch)
treed322cd4ea3257d9c95a2afd06da856de8d8bd87a /perl/Wallet/Server.pm
parent1cc39c41c7cd2a682d024526f4fe933f7e7722da (diff)
Initial work on supporting testing with MySQL.
Add a drop() method to Wallet::Schema to destroy the wallet database. Add a test suite for it. Add a reinitialize() method to Wallet;:Server that drops the database before creating it. Modify the wallet object test cases to call reinitialize() to create the initial database and drop() to clean up the database after the test is complete. Fix a bug preventing Wallet::Schema from being initialized multiple times. We now stash the schema in a class static variable and reuse it for subsequent initializations, since re-reading DATA doesn't work.
Diffstat (limited to 'perl/Wallet/Server.pm')
-rw-r--r--perl/Wallet/Server.pm21
1 files changed, 21 insertions, 0 deletions
diff --git a/perl/Wallet/Server.pm b/perl/Wallet/Server.pm
index 429b3fb..04e8fd9 100644
--- a/perl/Wallet/Server.pm
+++ b/perl/Wallet/Server.pm
@@ -85,6 +85,18 @@ sub initialize {
return $class->new ($user, 'localhost');
}
+# The same as initialize, but also drops any existing tables first before
+# creating the schema. Takes the same arguments and throws an exception on
+# failure.
+sub reinitialize {
+ my ($class, $user) = @_;
+ my $dbh = $class->_open_db;
+ my $schema = Wallet::Schema->new;
+ $schema->drop ($dbh);
+ $dbh->disconnect;
+ return $class->initialize ($user);
+}
+
# Create a new wallet server object. A new server should be created for each
# user who is making changes to the wallet. Takes the principal and host who
# are sending wallet requests. Opens a connection to the database that will
@@ -752,6 +764,15 @@ privileged operations.
On any error, this method throws an exception.
+=item reinitialize(PRINCIPAL)
+
+Performs the same actions as initialize(), but first drops any existing
+wallet database tables from the database, allowing this function to be
+called on a prior wallet database. All data stored in the database will be
+deleted and a fresh set of wallet database tables will be created.
+
+On any error, this method throws an exception.
+
=back
=head1 INSTANCE METHODS