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/Wallet/ACL.pm | |
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/Wallet/ACL.pm')
-rw-r--r-- | perl/Wallet/ACL.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/perl/Wallet/ACL.pm b/perl/Wallet/ACL.pm index 6a07366..f04217e 100644 --- a/perl/Wallet/ACL.pm +++ b/perl/Wallet/ACL.pm @@ -50,8 +50,12 @@ sub new { } else { $sql = 'select ac_id, ac_name from acls where ac_name = ?'; } - ($data, $name) = eval { $dbh->selectrow_array ($sql, undef, $id) }; + eval { + ($data, $name) = $dbh->selectrow_array ($sql, undef, $id); + $dbh->commit; + }; if ($@) { + $dbh->rollback; die "cannot search for ACL $id: $@\n"; } elsif (not defined $data) { die "ACL $id not found\n"; @@ -271,9 +275,11 @@ sub list { while (defined ($entry = $sth->fetchrow_arrayref)) { push (@entries, [ @$entry ]); } + $self->{dbh}->commit; }; if ($@) { $self->error ("cannot retrieve ACL $self->{id}: $@"); + $self->{dbh}->rollback; return; } else { return @entries; @@ -320,9 +326,11 @@ sub history { } $output .= "\n by $data[3] from $data[4]\n"; } + $self->{dbh}->commit; }; if ($@) { $self->error ("cannot read history for $self->{id}: $@"); + $self->{dbh}->rollback; return undef; } return $output; |