Bug 33834: Fix random failure on api/v1/ill_requests.t
This patch makes the GET request results more deterministic so we avoid
random failures. It does so by adding a fixed value to each ILL request
and then sorting by it.
To test:
1. Run:
$ DB_IMAGE=mysqli:8.0 ktd up -d
# wait until it finished:
$ ktd --logs
2. Run:
$ ktd --shell
k$ prove t/db_dependent/api/v1/ill_requests.t
(repeat a few times)
=> FAIL: It sometimes fails
3. Apply this patch
4. Repeat 2
=> SUCCESS: It doesn't fail
5. Sign off :-D
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 1a8903ae85
)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
parent
5052f9cec0
commit
4f28cd3227
1 changed files with 25 additions and 4 deletions
|
@ -139,9 +139,30 @@ subtest 'list() tests' => sub {
|
|||
};
|
||||
|
||||
# Create some ILL requests
|
||||
my $req_1 = $builder->build_object({ class => 'Koha::Illrequests', value => { borrowernumber => $patron->borrowernumber, status => $request_status->{code}, backend =>$backend->name } });
|
||||
my $req_2 = $builder->build_object({ class => 'Koha::Illrequests', value => { status => $request_status->{code}, backend =>$backend->name , status_alias => $av->authorised_value } } );
|
||||
my $ret = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'RET' } } );
|
||||
my $req_1 = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Illrequests',
|
||||
value => {
|
||||
borrowernumber => $patron->borrowernumber,
|
||||
status => $request_status->{code},
|
||||
backend => $backend->name,
|
||||
notesstaff => '1'
|
||||
}
|
||||
}
|
||||
);
|
||||
my $req_2 = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Illrequests',
|
||||
value => {
|
||||
status => $request_status->{code},
|
||||
backend => $backend->name,
|
||||
status_alias => $av->authorised_value,
|
||||
notesstaff => '2'
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
my $ret = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'RET' } });
|
||||
|
||||
# Three requests exist, expect all three to be returned
|
||||
$t->get_ok("//$userid:$password@/api/v1/ill/requests")
|
||||
|
@ -209,7 +230,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
# Hide 'RET', expect to return 2 'REQ'
|
||||
t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'RET' );
|
||||
$t->get_ok( "//$userid:$password@/api/v1/ill/requests" )
|
||||
$t->get_ok( "//$userid:$password@/api/v1/ill/requests?_order_by=staff_notes" )
|
||||
->status_is(200)
|
||||
->json_is( [ $req_1->to_api, $req_2->to_api ]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue