diff options
author | Jon Robertson <jonrober@stanford.edu> | 2013-03-28 23:53:52 -0700 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2013-03-29 13:41:59 -0700 |
commit | 2a8fb416b5eb2db697e03ddce930c21656ccbc88 (patch) | |
tree | 3f9bbf81a5646367f632a6d787ced3d8b7924b48 | |
parent | f31dca91d2ae2329e854251121553df0ee991bc0 (diff) |
admin.t: Fixed problem with not upgrading from unversioned db
Since we were reinstalling a fresh database via the same DBIx::Class
functions, the database we installed to upgrade from a non-versioned
setup was still getting a version table. Switched to delete the
database and reload it fresh from the sqlite3 command itself.
Change-Id: Ia09bbc279ab834b5d17453b4282e18dd3a36f857
Reviewed-on: https://gerrit.stanford.edu/993
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
-rwxr-xr-x | perl/t/admin.t | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/perl/t/admin.t b/perl/t/admin.t index a11b9b2..bf6ebce 100755 --- a/perl/t/admin.t +++ b/perl/t/admin.t @@ -8,7 +8,7 @@ # # See LICENSE for licensing terms. -use Test::More tests => 23; +use Test::More tests => 24; use Wallet::Admin; use Wallet::Report; @@ -57,18 +57,27 @@ 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. +# Test re-initialization of the database. $Wallet::Schema::VERSION = '0.07'; is ($admin->reinitialize ('admin@EXAMPLE.COM'), 1, ' and re-initialization succeeds'); $Wallet::Schema::VERSION = '0.08'; + +# Delete all tables and then redump them straight from the SQL file to avoid +# getting the version table. +unlink 'wallet-db'; +$admin = eval { Wallet::Admin->new }; +my $status = system ('/usr/bin/sqlite3', 'wallet-db', + '.read sql/Wallet-Schema-0.07-SQLite.sql'); +is ($status, 0, 'Reinstalling database from non-versioned version succeds'); + +# Test an upgrade. Reinitialize to an older version, then test upgrade to +# the current version. my $retval = $admin->upgrade; -is ($retval, 1, 'Performing an upgrade succeeds'); -my $dbh = $admin->dbh; +is ($retval, 1, ' and performing an upgrade succeeds'); my $sql = "select version from dbix_class_schema_versions order by version " ."DESC"; -$version = $dbh->selectall_arrayref ($sql); +$version = $admin->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'); |