diff options
author | Russ Allbery <rra@stanford.edu> | 2007-11-30 02:04:14 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2007-11-30 02:04:14 +0000 |
commit | 1e13c0c60c96dd1719e7c4c3931b4196c2b5bc61 (patch) | |
tree | d322cd4ea3257d9c95a2afd06da856de8d8bd87a /perl/t/init.t | |
parent | 1cc39c41c7cd2a682d024526f4fe933f7e7722da (diff) |
Initial work on supporting testing with MySQL.
Add a drop() method to Wallet::Schema to destroy the wallet database. Add
a test suite for it. Add a reinitialize() method to Wallet;:Server that
drops the database before creating it.
Modify the wallet object test cases to call reinitialize() to create the
initial database and drop() to clean up the database after the test is
complete.
Fix a bug preventing Wallet::Schema from being initialized multiple times.
We now stash the schema in a class static variable and reuse it for
subsequent initializations, since re-reading DATA doesn't work.
Diffstat (limited to 'perl/t/init.t')
-rwxr-xr-x | perl/t/init.t | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/perl/t/init.t b/perl/t/init.t index 3fa026f..81c034d 100755 --- a/perl/t/init.t +++ b/perl/t/init.t @@ -8,7 +8,7 @@ # # See LICENSE for licensing terms. -use Test::More tests => 8; +use Test::More tests => 16; use Wallet::ACL; use Wallet::Config; @@ -34,5 +34,22 @@ isnt ($entries[0], undef, ' which is a valid entry'); is ($entries[0][0], 'krb5', ' of krb5 scheme'); is ($entries[0][1], 'admin@EXAMPLE.COM', ' with the right user'); +# Test reinitialization. +$server = eval { Wallet::Server->reinitialize ('admin@EXAMPLE.COM') }; +is ($@, '', 'Reinitialization did not die'); +ok ($server->isa ('Wallet::Server'), ' and returned the right class'); + +# Now repeat the database content checks. +$acl = eval { Wallet::ACL->new ('ADMIN', $server->dbh) }; +is ($@, '', 'Retrieving ADMIN ACL successful'); +ok ($acl->isa ('Wallet::ACL'), ' and is the right class'); +@entries = $acl->list; +is (scalar (@entries), 1, ' and has only one entry'); +isnt ($entries[0], undef, ' which is a valid entry'); +is ($entries[0][0], 'krb5', ' of krb5 scheme'); +is ($entries[0][1], 'admin@EXAMPLE.COM', ' with the right user'); + # Clean up. +my $schema = Wallet::Schema->new; +$schema->drop ($server->dbh); unlink 'wallet-db'; |