aboutsummaryrefslogtreecommitdiff
path: root/perl/t/admin.t
diff options
context:
space:
mode:
Diffstat (limited to 'perl/t/admin.t')
-rwxr-xr-xperl/t/admin.t21
1 files changed, 20 insertions, 1 deletions
diff --git a/perl/t/admin.t b/perl/t/admin.t
index 6250f8e..cf6a637 100755
--- a/perl/t/admin.t
+++ b/perl/t/admin.t
@@ -8,12 +8,13 @@
#
# See LICENSE for licensing terms.
-use Test::More tests => 18;
+use Test::More tests => 23;
use Wallet::Admin;
use Wallet::Report;
use Wallet::Schema;
use Wallet::Server;
+use DBI;
use lib 't/lib';
use Util;
@@ -56,6 +57,24 @@ is ($admin->register_verifier ('base', 'Wallet::ACL::Base'), undef,
is ($server->acl_add ('ADMIN', 'base', 'foo'), 1,
' and adding a base ACL now works');
+# Test an upgrade. Reinitialize to an older version, then test upgrade to
+# the current version.
+$Wallet::Schema::VERSION = '0.07';
+is ($admin->reinitialize ('admin@EXAMPLE.COM'), 1,
+ ' and re-initialization succeeds');
+$Wallet::Schema::VERSION = '0.08';
+my $schema = $admin->dbh;
+$schema->upgrade_directory ('sql/');
+my $retval = $admin->upgrade;
+is ($retval, 1, 'Performing an upgrade succeeds');
+my $dbh = $schema->storage->dbh;
+my $sql = "select version from dbix_class_schema_versions order by version "
+ ."DESC";
+$version = $dbh->selectall_arrayref ($sql);
+is (@$version, 2, ' and versions table has correct number of rows');
+is (@{ $version->[0] }, 1, ' and correct number of columns');
+is ($version->[0][0], '0.08', ' and the schema version is correct');
+
# Clean up.
is ($admin->destroy, 1, 'Destruction succeeds');
unlink 'wallet-db';