From 8b057ec4e08ce0f3dfdec5f581d7348b2ad4cf76 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 22 Nov 2024 13:29:02 +0000 Subject: [PATCH] Bug 36822: Improve datetime comparison in tests This removes the seconds part of the datetime comparison because when running tests this may mismatch causing tests to become flaky. The previous patch 'Fix now time in tests' was not enough to prevent this. prove t/db_dependent/Auth_with_ldap.t prove t/db_dependent/Auth_with_shibboleth.t --- t/db_dependent/Auth_with_ldap.t | 7 ++++--- t/db_dependent/Auth_with_shibboleth.t | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/t/db_dependent/Auth_with_ldap.t b/t/db_dependent/Auth_with_ldap.t index 38f4dbca16..249ce6df87 100755 --- a/t/db_dependent/Auth_with_ldap.t +++ b/t/db_dependent/Auth_with_ldap.t @@ -276,12 +276,13 @@ subtest 'checkpw_ldap tests' => sub { $welcome = 0; # replicate testing with checkpw - my $time_now = dt_from_string()->ymd . ' ' . dt_from_string()->hms; C4::Auth::checkpw( 'hola', password => 'hey' ); my $patron_replicated_from_auth = Koha::Patrons->search( { userid => 'hola' } )->next; + my $patrons_updated_on = $patron_replicated_from_auth->updated_on; + $patrons_updated_on =~ s/:\d+$//; is( - $patron_replicated_from_auth->updated_on, $time_now, - "updated_on correctly saved on newly created user" + $patrons_updated_on, dt_from_string()->strftime('%Y-%m-%d %H:%M'), + "updated_on correctly saved on newly created user, ignoring seconds" ); $patron_replicated_from_auth->delete; diff --git a/t/db_dependent/Auth_with_shibboleth.t b/t/db_dependent/Auth_with_shibboleth.t index 18b27124b3..f755752997 100755 --- a/t/db_dependent/Auth_with_shibboleth.t +++ b/t/db_dependent/Auth_with_shibboleth.t @@ -309,16 +309,17 @@ subtest "checkpw_shib tests" => sub { $ENV{'emailpro'} = 'me@myemail.com'; $ENV{branchcode} = $library->branchcode; # needed since T::D::C does no longer hides the FK constraint - my $time_now = dt_from_string()->ymd . ' ' . dt_from_string()->hms; checkpw($shib_login); ok my $new_user_autocreated = $schema->resultset('Borrower')->search( { 'userid' => 'test43210' }, { rows => 1 } ), "new user found"; my $rec_autocreated = $new_user_autocreated->next; + my $patrons_updated_on = $rec_autocreated->updated_on; + $patrons_updated_on =~ s/:\d+$//; is_deeply( - [ map { $rec_autocreated->$_ } qw/updated_on/ ], - [$time_now], - 'updated_on correctly saved on newly created user' + [$patrons_updated_on], + [ dt_from_string()->strftime('%Y-%m-%d %H:%M') ], + 'updated_on correctly saved on newly created user, ignoring seconds' ); }; -- 2.39.5