From 7f1ccd1cb73cc36668821238661ead1004fe1406 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Tue, 17 May 2011 15:28:13 -0700 Subject: Add metadata table to the wallet database Add a metadata table whose only column, currently, is a version number. We will store the version of the schema in this table and use that to know what to do during upgrades. --- perl/t/schema.t | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'perl/t') diff --git a/perl/t/schema.t b/perl/t/schema.t index 40759db..11774d6 100755 --- a/perl/t/schema.t +++ b/perl/t/schema.t @@ -3,11 +3,12 @@ # Tests for the wallet schema class. # # Written by Russ Allbery -# Copyright 2007, 2008 Board of Trustees, Leland Stanford Jr. University +# Copyright 2007, 2008, 2011 +# The Board of Trustees of the Leland Stanford Junior University # # See LICENSE for licensing terms. -use Test::More tests => 8; +use Test::More tests => 11; use DBI; use Wallet::Config; @@ -21,7 +22,7 @@ ok (defined $schema, 'Wallet::Schema creation'); ok ($schema->isa ('Wallet::Schema'), ' and class verification'); my @sql = $schema->sql; ok (@sql > 0, 'sql() returns something'); -is (scalar (@sql), 29, ' and returns the right number of statements'); +is (scalar (@sql), 31, ' and returns the right number of statements'); # Connect to a database and test create. db_setup; @@ -37,6 +38,13 @@ $dbh->{PrintError} = 0; eval { $schema->create ($dbh) }; is ($@, '', "create() doesn't die"); +# Check that the version number is correct. +my $sql = "select md_version from metadata"; +my $version = $dbh->selectall_arrayref ($sql); +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 dropping the database. eval { $schema->drop ($dbh) }; is ($@, '', "drop() doesn't die"); -- cgit v1.2.3