summaryrefslogtreecommitdiff
path: root/perl/t/schema.t
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2011-05-17 15:53:41 -0700
committerRuss Allbery <rra@stanford.edu>2011-05-17 15:53:41 -0700
commitdeaa5c140e85d8e1248d910f0721c9e00a46e439 (patch)
treeee1f29f6e9464df2f70df54c9fe0db5811774500 /perl/t/schema.t
parent7f1ccd1cb73cc36668821238661ead1004fe1406 (diff)
Support database upgrades from version 0
Version 0 is the version without the metadata table. Add a new upgrade method to Wallet::Schema and support upgrading the database to version 1. (Version 1 is not yet finalized.)
Diffstat (limited to 'perl/t/schema.t')
-rwxr-xr-xperl/t/schema.t11
1 files changed, 10 insertions, 1 deletions
diff --git a/perl/t/schema.t b/perl/t/schema.t
index 11774d6..c66ad59 100755
--- a/perl/t/schema.t
+++ b/perl/t/schema.t
@@ -8,7 +8,7 @@
#
# See LICENSE for licensing terms.
-use Test::More tests => 11;
+use Test::More tests => 15;
use DBI;
use Wallet::Config;
@@ -45,6 +45,15 @@ is (@$version, 1, 'metadata has correct number of rows');
is (@{ $version->[0] }, 1, ' and correct number of columns');
is ($version->[0][0], 1, ' and the schema version is correct');
+# Test upgrading the database from version 0.
+$dbh->do ("drop table metadata");
+eval { $schema->upgrade ($dbh) };
+is ($@, '', "upgrade() doesn't die");
+$version = $dbh->selectall_arrayref ($sql);
+is (@$version, 1, ' and metadata has correct number of rows');
+is (@{ $version->[0] }, 1, ' and correct number of columns');
+is ($version->[0][0], 1, ' and the schema version is correct');
+
# Test dropping the database.
eval { $schema->drop ($dbh) };
is ($@, '', "drop() doesn't die");