summaryrefslogtreecommitdiff
path: root/perl/t/schema.t
blob: 01b2b88c09db188ff06dbc3d6edd33ea12b501de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl -w
# $Id$
#
# t/schema.t -- Tests for the wallet schema class.
#
# Written by Russ Allbery <rra@stanford.edu>
# Copyright 2007 Board of Trustees, Leland Stanford Jr. University
#
# See LICENSE for licensing terms.

use Test::More tests => 5;

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), 26, ' and returns the right number of statements');

# Create a SQLite database to use for create.
unlink 'wallet-db';
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");

# Clean up.
unlink 'wallet-db';