Bugzilla – Attachment 136375 Details for
Bug 30889
Background jobs lead to wrong/missing info in logs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30889: Unit tests
Bug-30889-Unit-tests.patch (text/plain), 3.42 KB, created by
Martin Renvoize (ashimema)
on 2022-06-20 15:02:59 UTC
(
hide
)
Description:
Bug 30889: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-06-20 15:02:59 UTC
Size:
3.42 KB
patch
obsolete
>From 887df6b8ab132835f18106f0dc5138b9d95091b8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 20 Jun 2022 16:01:28 +0100 >Subject: [PATCH] Bug 30889: Unit tests > >This patch adds a unit test for the 'enqueue' part of the bug. We check >that the mocked context (and interface) are recorded with the job >enqueue in the new 'context' field. > >We do not yet test the 'process' end, where we then read the context out >and set the job Context from it. >--- > t/db_dependent/Koha/BackgroundJob.t | 23 +++++++++++++++++++++-- > t/lib/Mocks.pm | 2 +- > 2 files changed, 22 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Koha/BackgroundJob.t b/t/db_dependent/Koha/BackgroundJob.t >index 0cdaa2f93c..68bea92fe1 100755 >--- a/t/db_dependent/Koha/BackgroundJob.t >+++ b/t/db_dependent/Koha/BackgroundJob.t >@@ -65,7 +65,7 @@ subtest '_derived_class() tests' => sub { > > subtest 'enqueue() tests' => sub { > >- plan tests => 6; >+ plan tests => 7; > > $schema->storage->txn_begin; > >@@ -77,15 +77,34 @@ subtest 'enqueue() tests' => sub { > is( $job->status, 'new', 'Initial status set correctly' ); > is( $job->borrowernumber, undef, 'No userenv, borrowernumber undef' ); > >+ my $interface = C4::Context->interface; > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > t::lib::Mocks::mock_userenv( { patron => $patron } ); >+ my $job_context = { >+ number => $patron->borrowernumber, >+ id => $patron->userid, >+ cardnumber => $patron->cardnumber, >+ firstname => $patron->firstname, >+ surname => $patron->surname, >+ branch => $patron->library->branchcode, >+ branchname => $patron->library->branchname, >+ flags => $patron->flags, >+ emailaddress => $patron->email, >+ register_id => undef, >+ register_name => undef, >+ shibboleth => undef, >+ desk_id => undef, >+ desk_name => undef, >+ interface => $interface >+ }; > > $job_id = Koha::BackgroundJob::BatchUpdateItem->new->enqueue( { record_ids => [ 1, 2, 3 ] } ); > $job = Koha::BackgroundJobs->find($job_id)->_derived_class; > > is( $job->size, 3, 'Three steps' ); > is( $job->status, 'new', 'Initial status set correctly' ); >- is( $job->borrowernumber, $patron->id, 'No userenv, borrowernumber undef' ); >+ is( $job->borrowernumber, $patron->id, 'Borrowernumber set from userenv' ); >+ is_deeply( decode_json( $job->context ), $job_context, 'Context set from userenv + interface' ); > > $schema->storage->txn_rollback; > }; >diff --git a/t/lib/Mocks.pm b/t/lib/Mocks.pm >index 0eaf2106bc..68d8829ca6 100644 >--- a/t/lib/Mocks.pm >+++ b/t/lib/Mocks.pm >@@ -131,7 +131,7 @@ sub mock_userenv { > my $branchcode = $params->{branchcode} || $userenv->{branchcode} || 'Branch4T'; > my $branchname = $params->{branchname} || $userenv->{branchname}; > my $flags = $params->{flags} || $userenv->{flags} || 0; >- my $emailaddress = $params->{emailaddress} || $userenv->{emailaddress}; >+ my $emailaddress = $params->{emailaddress} || $userenv->{email}; > my $desk_id = $params->{desk_id} || $userenv->{desk_id}; > my $desk_name = $params->{desk_name} || $userenv->{desk_name}; > my $register_id = $params->{register_id} || $userenv->{register_id}; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30889
:
135759
|
135760
|
135932
|
135933
|
135934
|
135935
|
135936
|
136294
|
136295
|
136296
|
136297
|
136298
|
136299
|
136375
|
136376
|
136784
|
136785
|
136786
|
136787
|
136788
|
136789
|
136790
|
136791
|
136792
|
136904
|
136948