From 794d34a79f189a9ecc27b6c0aab332e75c0a46b0 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 20 Dec 2015 18:49:52 -0800 Subject: [PATCH] Test begin work/commit nesting in a few places. I discovered a bug where _beginWork() and _commit() calls were not properly matched. These tests are added to find them. --- Supporters/t/Supporters.t | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Supporters/t/Supporters.t b/Supporters/t/Supporters.t index 587977e..2967996 100644 --- a/Supporters/t/Supporters.t +++ b/Supporters/t/Supporters.t @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 154; +use Test::More tests => 158; use Test::Exception; use Scalar::Util qw(looks_like_number reftype); @@ -223,6 +223,8 @@ my $tShirt0Data; dies_ok { $sp->addRequestConfigurations('t-shirt-1', [ @sizeList, 'Men2XL']) } "addRequestConfigurations: dies with duplicate items on configuration list."; +is($sp->{__NESTED_TRANSACTION_COUNTER__}, 0, "addRequestConfigurations: assure proper beginWork/commit matching."); + is_deeply($sp->getRequestConfigurations('t-shirt-1'), undef, "addRequestConfigurations/getRequestConfigurations: add fails with undefined configuration list"); @@ -232,6 +234,8 @@ lives_ok { $tShirt0Data = $sp->addRequestConfigurations('t-shirt-0', \@sizeList) is( keys %{$tShirt0Data}, ($tShirt0RequestTypeId), "addRequestConfigurations: reuses same requestTypeId on add of configurations"); +is($sp->{__NESTED_TRANSACTION_COUNTER__}, 0, "addRequestConfigurations: assure proper beginWork/commit matching."); + my $cnt = 0; foreach my $size (@sizeList) { ok( (defined $tShirt0Data->{$tShirt0RequestTypeId}{$size} and @@ -256,6 +260,8 @@ dies_ok { $sp->addRequest({ supporterId => 0, requestTypeId => $tShirt0RequestTy dies_ok { $sp->addRequest({ supporterId => $drapperId, requestTypeId => 0 }); } "addRequest: dies if requestTypeId invalid."; +is($sp->{__NESTED_TRANSACTION_COUNTER__}, 0, "addRequest: assure proper beginWork/commit matching."); + my $emailListRequestId; lives_ok { $emailListRequestId = @@ -458,11 +464,12 @@ lives_ok { $ret = $sp->setPreferredEmailAddress($drapperId, 'drapper@example.org ok( (defined $ret and looks_like_number($ret) and $ret == $drapperEmailId), "setPreferredEmailAddress: ... and returns correct email_address_id on success"); +is($sp->{__NESTED_TRANSACTION_COUNTER__}, 0, "setPreferredEmailAddress: assure proper beginWork/commit matching."); + lives_ok { $ret = $sp->getPreferredEmailAddress($drapperId) } "getPreferredEmailAddress: lookup of known preferred email address succeeds... "; is($ret, 'drapper@example.org', "getPreferredEmailAddress: ....and returns the correct value."); - =back =item Internal methods used only by the module itself.