From e58bb168ff9d89a364e1a044fd05dc17fcfee053 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 8 Sep 2025 10:21:55 +0200 Subject: [PATCH] Bug 22632: Prevent tests to fail randomly Jenkins was failing on Koha_Master/3350 With this patch we won't rely on the order (timestamp are identical and may not be sorted as expected) 23:56:28 koha-1 | # Failed test 'GetLogs returns results in the log viewer for the merge of 526' 23:56:28 koha-1 | # at t/db_dependent/Koha/Patron/Log.t line 67. 23:56:28 koha-1 | # got: 'G7X8jre jVr_oz8M (eQXWiW9b4jX16424uC3Chn) has been merged into Mwqx7a zkSkFX7 (y_L7flupzFShb8JWYVCwYGSuv)' 23:56:28 koha-1 | # expected: 'exgnQtw lLmxQL9eWY (nHc_VZdFHIXr90p6WrIijDPgFrz8JM38) has been merged into Mwqx7a zkSkFX7 (y_L7flupzFShb8JWYVCwYGSuv)' 23:56:28 koha-1 | 23:56:28 koha-1 | # Failed test 'GetLogs returns results in the log viewer for the merge of 527' 23:56:28 koha-1 | # at t/db_dependent/Koha/Patron/Log.t line 82. 23:56:28 koha-1 | # got: 'exgnQtw lLmxQL9eWY (nHc_VZdFHIXr90p6WrIijDPgFrz8JM38) has been merged into Mwqx7a zkSkFX7 (y_L7flupzFShb8JWYVCwYGSuv)' 23:56:28 koha-1 | # expected: 'G7X8jre jVr_oz8M (eQXWiW9b4jX16424uC3Chn) has been merged into Mwqx7a zkSkFX7 (y_L7flupzFShb8JWYVCwYGSuv)' 23:56:28 koha-1 | # Looks like you failed 2 tests of 4. 23:56:28 koha-1 | 23:56:28 koha-1 | # Failed test 'Test Koha::Patrons::merge' 23:56:28 koha-1 | # at t/db_dependent/Koha/Patron/Log.t line 113. --- t/db_dependent/Koha/Patron/Log.t | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/t/db_dependent/Koha/Patron/Log.t b/t/db_dependent/Koha/Patron/Log.t index 8734497ce61..4e0fd28d697 100755 --- a/t/db_dependent/Koha/Patron/Log.t +++ b/t/db_dependent/Koha/Patron/Log.t @@ -27,7 +27,7 @@ $schema->storage->txn_begin; subtest 'Test Koha::Patrons::merge' => sub { - plan tests => 4; + plan tests => 3; my $builder = t::lib::TestBuilder->new; my $keeper = $builder->build_object( { class => 'Koha::Patrons' } ); @@ -49,7 +49,7 @@ subtest 'Test Koha::Patrons::merge' => sub { object => $keeper->id }, { order_by => { -desc => "timestamp" } } - )->unblessed; + ); my $info_borrower1 = $borrower1->{firstname} . " " @@ -59,10 +59,9 @@ subtest 'Test Koha::Patrons::merge' => sub { . $keeper->firstname . " " . $keeper->surname . " (" . $keeper->cardnumber . ")"; - my $info_log = $log->[0]{info}; is( - $info_log, $info_borrower1, + $log->search( { info => $info_borrower1 } )->count, 1, "GetLogs returns results in the log viewer for the merge of " . $borrower1->{borrowernumber} ); @@ -74,10 +73,9 @@ subtest 'Test Koha::Patrons::merge' => sub { . $keeper->firstname . " " . $keeper->surname . " (" . $keeper->cardnumber . ")"; - $info_log = $log->[1]{info}; is( - $info_log, $info_borrower2, + $log->search( { info => $info_borrower2 } )->count, 1, "GetLogs returns results in the log viewer for the merge of " . $borrower2->{borrowernumber} ); @@ -95,20 +93,11 @@ subtest 'Test Koha::Patrons::merge' => sub { object => $keeper->id }, { order_by => { -desc => "timestamp" } } - )->unblessed; - - $info_log = $log->[0]{info}; - - is( - $info_log, undef, - "GetLogs didn't returns results in the log viewer for the merge of " . $borrower3->{borrowernumber} ); - $info_log = $log->[1]{info}; - is( - $info_log, undef, - "GetLogs didn't returns results in the log viewer for the merge of " . $borrower4->{borrowernumber} + $log->count, 0, + "GetLogs didn't log anything" ); }; -- 2.34.1