From fed444c006e8d6cf66d93c2091047e7f671d75ae Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 21 Apr 2021 09:44:58 +0200 Subject: [PATCH] Bug 27857: Start a transaction foreach subtest There is a random failure # Looks like you planned 15 tests but ran 2. # Failed test 'extended_attributes' # at t/db_dependent/Koha/Patron.t line 664. Missing mandatory extended attribute (type=B0vCQxlI)# Looks like your test exited with 255 just after 7. [17:00:24] t/db_dependent/Koha/Patron.t --- t/db_dependent/Koha/Patron.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index c5a2cbfd90..7bcd427da4 100755 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -499,10 +499,14 @@ subtest 'extended_attributes' => sub { #$limited_value = $patron_1->get_extended_attribute( $attribute_type_limited->code ); #is( $limited_value, undef, ); + $schema->storage->txn_rollback; + subtest 'non-repeatable attributes tests' => sub { plan tests => 3; + $schema->storage->txn_begin; + my $patron = $builder->build_object({ class => 'Koha::Patrons' }); my $attribute_type = $builder->build_object( { @@ -526,12 +530,17 @@ subtest 'extended_attributes' => sub { 'Exception thrown on non-repeatable attribute'; is( $patron->extended_attributes->count, 0, 'Extended attributes storing rolled back' ); + + $schema->storage->txn_rollback; + }; subtest 'unique attributes tests' => sub { plan tests => 5; + $schema->storage->txn_begin; + my $patron_1 = $builder->build_object({ class => 'Koha::Patrons' }); my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); @@ -573,12 +582,17 @@ subtest 'extended_attributes' => sub { is( $patron_1->extended_attributes->count, 2, 'Extended attributes stored' ); is( $patron_2->extended_attributes->count, 0, 'Extended attributes storing rolled back' ); + + $schema->storage->txn_rollback; + }; subtest 'invalid type attributes tests' => sub { plan tests => 3; + $schema->storage->txn_begin; + my $patron = $builder->build_object({ class => 'Koha::Patrons' }); my $attribute_type_1 = $builder->build_object( @@ -612,12 +626,17 @@ subtest 'extended_attributes' => sub { 'Exception thrown on invalid attribute type'; is( $patron->extended_attributes->count, 0, 'Extended attributes storing rolled back' ); + + $schema->storage->txn_rollback; + }; subtest 'globally mandatory attributes tests' => sub { plan tests => 5; + $schema->storage->txn_begin; + my $patron = $builder->build_object({ class => 'Koha::Patrons' }); my $attribute_type_1 = $builder->build_object( @@ -658,7 +677,9 @@ subtest 'extended_attributes' => sub { ); is( $patron->extended_attributes->count, 1, 'Extended attributes succeeded' ); + + $schema->storage->txn_rollback; + }; - $schema->storage->txn_rollback; }; -- 2.20.1