From 1e13c0c60c96dd1719e7c4c3931b4196c2b5bc61 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Fri, 30 Nov 2007 02:04:14 +0000 Subject: 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. --- perl/Wallet/ACL.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'perl/Wallet/ACL.pm') 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; -- cgit v1.2.3