From 3ca875d70c2f7415675ebcceef261c1224f03db0 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Fri, 29 Mar 2013 13:56:45 -0700 Subject: Make t/admin.t test robust against missing sqlite3 binary If we can't find the sqlite3 binary, just skip the upgrade test. Reviewed-on: https://gerrit.stanford.edu/994 Reviewed-by: Russ Allbery Tested-by: Russ Allbery (cherry picked from commit 15fea5552df18667b39fce620488ed6c48bd7329) Change-Id: I26cd8148d58368767f39d135afe4c721652b0740 --- perl/t/admin.t | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'perl') diff --git a/perl/t/admin.t b/perl/t/admin.t index bf6ebce..740c79e 100755 --- a/perl/t/admin.t +++ b/perl/t/admin.t @@ -3,7 +3,7 @@ # Tests for wallet administrative interface. # # Written by Russ Allbery -# Copyright 2008, 2009, 2010, 2011 +# Copyright 2008, 2009, 2010, 2011, 2013 # The Board of Trustees of the Leland Stanford Junior University # # See LICENSE for licensing terms. @@ -63,24 +63,29 @@ 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. +SKIP: { + my @path = (split (':', $ENV{PATH})); + my ($sqlite) = grep { -x $_ } map { "$_/sqlite3" } @path; + skip 'sqlite3 not found', 5 unless $sqlite; -# Test an upgrade. Reinitialize to an older version, then test upgrade to -# the current version. -my $retval = $admin->upgrade; -is ($retval, 1, ' and performing an upgrade succeeds'); -my $sql = "select version from dbix_class_schema_versions order by version " - ."DESC"; -$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'); + # 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 ('sqlite3', 'wallet-db', + '.read sql/Wallet-Schema-0.07-SQLite.sql'); + is ($status, 0, 'Reinstalling database from non-versioned SQL succeds'); + my $retval = $admin->upgrade; + is ($retval, 1, ' and performing an upgrade succeeds'); + my $sql = "select version from dbix_class_schema_versions order by" + . " version DESC"; + $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'); +} # Clean up. is ($admin->destroy, 1, 'Destruction succeeds'); -- cgit v1.2.3