Bug 19775: Try & prevent Search/History.t to fail randomly
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 7 Dec 2017 16:41:06 +0000 (13:41 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 7 Dec 2017 16:42:45 +0000 (13:42 -0300)
 #   Failed test 'There are still 8 searches after calling delete with an interval = 6 days'
 #   at t/db_dependent/Search/History.t line 185.
 #          got: '6'
 #     expected: '8'

 #   Failed test 'There are still 2 searches after calling delete with an interval = 2 days'
 #   at t/db_dependent/Search/History.t line 191.
 #          got: '0'
 #     expected: '2'
 # Looks like you failed 2 tests of 27.
[15:04:12] t/db_dependent/Search/History.t

It looks like it does not longer fail with this change (date comparaison wrongly rounded to second in mysql?)

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Search/History.t

index fc7f063..92b3f4f 100644 (file)
@@ -233,10 +233,10 @@ delete_all( $userid );
 sub add {
     my ( $userid, $current_session_id, $previous_sessionid, $total, $query_cgi_b, $query_cgi_a ) = @_;
 
-    my $days_ago_2 = dt_from_string()->add_duration( DateTime::Duration->new( days => -2 ) );
-    my $days_ago_4 = dt_from_string()->add_duration( DateTime::Duration->new( days => -4 ) );
-    my $days_ago_6 = dt_from_string()->add_duration( DateTime::Duration->new( days => -6 ) );
-    my $days_ago_8 = dt_from_string()->add_duration( DateTime::Duration->new( days => -8 ) );
+    my $days_ago_2 = dt_from_string()->add_duration( DateTime::Duration->new( days => -2, minutes => 1 ) );
+    my $days_ago_4 = dt_from_string()->add_duration( DateTime::Duration->new( days => -4, minutes => 1 ) );
+    my $days_ago_6 = dt_from_string()->add_duration( DateTime::Duration->new( days => -6, minutes => 1 ) );
+    my $days_ago_8 = dt_from_string()->add_duration( DateTime::Duration->new( days => -8, minutes => 1 ) );
 
     my $query_desc_b1_p = q{first previous biblio search};
     my $first_previous_biblio_search = {