diff options
author | Russ Allbery <rra@stanford.edu> | 2007-08-29 22:25:59 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2007-08-29 22:25:59 +0000 |
commit | e8a4e031eb1604d8a3c61baf7340c986833ec986 (patch) | |
tree | fcc96fdda7f27a367655aa4976efdbf66bec0aba /perl/t | |
parent | 47e73096c95c9de797b54feb6dfedef2211bf7b3 (diff) |
Fix lots of problems with the schema and rework it a little bit to be
compatible with SQLite. Mostly this involves creating indexes
separately rather than part of the create table statement.
Diffstat (limited to 'perl/t')
-rwxr-xr-x | perl/t/schema.t | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/perl/t/schema.t b/perl/t/schema.t new file mode 100755 index 0000000..4c5105d --- /dev/null +++ b/perl/t/schema.t @@ -0,0 +1,28 @@ +#!/usr/bin/perl -w +# $Id$ +# +# t/schema.t -- Tests for the wallet schema class. + +use Test::More tests => 5; + +use DBD::SQLite; +use DBI; +use Wallet::Schema; + +my $schema = Wallet::Schema->new; +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), 22, ' and returns the right number of statements'); + +# Create a SQLite database to use for create. +my $dbh = DBI->connect ("DBI:SQLite:wallet-db"); +if (not defined $dbh) { + die "cannot create database wallet-db: $DBI::errstr\n"; +} +$dbh->{RaiseError} = 1; +$dbh->{PrintError} = 0; +eval { $schema->create ($dbh) }; +is ($@, '', "create() doesn't die"); +unlink 'wallet-db'; |