From d9b2cac8fd530c6b0b3df2469396119df21caf56 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 4 Nov 2024 11:32:34 +0000 Subject: [PATCH] Bug 36822: (QA follow-up): Fix now time in tests This is to prevent the scenario of tests failing if they take long to run, e.g.: # Failed test 'updated_on correctly saved on newly created user' # at t/db_dependent/Auth_with_shibboleth.t line 317. # Structures begin differing at: # ->[0] = '2024-11-04 11:20:13' # ->[0] = '2024-11-04 11:20:14 --- t/db_dependent/Auth_with_ldap.t | 3 ++- t/db_dependent/Auth_with_shibboleth.t | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Auth_with_ldap.t b/t/db_dependent/Auth_with_ldap.t index 8f7e87f38b..38f4dbca16 100755 --- a/t/db_dependent/Auth_with_ldap.t +++ b/t/db_dependent/Auth_with_ldap.t @@ -276,10 +276,11 @@ 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; is( - $patron_replicated_from_auth->updated_on, dt_from_string()->ymd . ' ' . dt_from_string()->hms, + $patron_replicated_from_auth->updated_on, $time_now, "updated_on correctly saved on newly created user" ); diff --git a/t/db_dependent/Auth_with_shibboleth.t b/t/db_dependent/Auth_with_shibboleth.t index 5f1d8be0cd..18b27124b3 100755 --- a/t/db_dependent/Auth_with_shibboleth.t +++ b/t/db_dependent/Auth_with_shibboleth.t @@ -309,6 +309,7 @@ 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"; @@ -316,7 +317,7 @@ subtest "checkpw_shib tests" => sub { my $rec_autocreated = $new_user_autocreated->next; is_deeply( [ map { $rec_autocreated->$_ } qw/updated_on/ ], - [ dt_from_string()->ymd . ' ' . dt_from_string()->hms ], + [$time_now], 'updated_on correctly saved on newly created user' ); }; -- 2.39.5