From 3f556c45695781cc50fa746975550af7818c7f32 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 28 Feb 2020 14:22:34 +0100 Subject: [PATCH] Bug 24760: Use C4::BackgroundJob->fetch in tests Starting with YAML 1.30 and YAML::Syck 1.32, these modules don't bless loaded objects by default. This is not a problem as C4::BackgroundJob->fetch bless them anyway. So, instead of testing what's in the session, test the result of C4::BackgroundJob->fetch, which is what's used everywhere else Test plan: 1. Install latest version of YAML::Syck (or YAML if YAML::Syck is not installed) 2. prove t/db_dependent/BackgroundJob.t => should FAIL 3. Apply patch 4. prove t/db_dependent/BackgroundJob.t => should PASS 5. Verify that background jobs are still working (for instance, tools/batchMod.pl) Signed-off-by: Michal Denar Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit c1c3cfed5ca2709b99587e8907b68d158ce013f9) Signed-off-by: Lucas Gass --- t/db_dependent/BackgroundJob.t | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/BackgroundJob.t b/t/db_dependent/BackgroundJob.t index ae5c25a78d..81a295979d 100644 --- a/t/db_dependent/BackgroundJob.t +++ b/t/db_dependent/BackgroundJob.t @@ -50,10 +50,8 @@ is( $job->status, 'completed', "testing finished" ); ok( $job->results ); #Will return undef unless finished my $second_job = C4::BackgroundJob->new( $sessionID, "making new job" ); -$session = C4::Auth::get_session( $job->{sessionID} ); -is( ref( $session->param( 'job_' . $job->id ) ), "C4::BackgroundJob", 'job_$jobid should be a C4::BackgroundJob for uncleared job 1' ); -is( ref( $session->param( 'job_' . $second_job->id ) ), "C4::BackgroundJob", 'job_$jobid should be a C4::BackgroundJob for uncleared job 2' ); +is( ref( C4::BackgroundJob->fetch( $sessionID, $job->id ) ), "C4::BackgroundJob", 'job_$jobid should be a C4::BackgroundJob for uncleared job 1' ); +is( ref( C4::BackgroundJob->fetch( $sessionID, $second_job->id ) ), "C4::BackgroundJob", 'job_$jobid should be a C4::BackgroundJob for uncleared job 2' ); $job->clear; -$session = C4::Auth::get_session( $job->{sessionID} ); -is( $session->param( 'job_' . $job->id ), undef, 'After clearing it, job 1 should not exist anymore in the session' ); -is( ref( $session->param( 'job_' . $second_job->id ) ), "C4::BackgroundJob", 'After clear on job 1, job 2 should still be a C4::BackgroundJob' ); +is( C4::BackgroundJob->fetch( $sessionID, $job->id ), undef, 'After clearing it, job 1 should not exist anymore in the session' ); +is( ref( C4::BackgroundJob->fetch( $sessionID, $second_job->id ) ), "C4::BackgroundJob", 'After clear on job 1, job 2 should still be a C4::BackgroundJob' ); -- 2.39.5