From f228ffcffe32ec77235260d79371a65690d96a7e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 15 Aug 2023 13:14:42 +0100 Subject: [PATCH] Bug 24401: (QA follow-up) Fix failing test --- t/db_dependent/api/v1/checkouts.t | 44 +++++++++++++------------------ 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t index 9310bef345..3263551ca8 100755 --- a/t/db_dependent/api/v1/checkouts.t +++ b/t/db_dependent/api/v1/checkouts.t @@ -473,7 +473,7 @@ subtest 'add checkout' => sub { my $token = Koha::Token->new->generate_jwt( { id => $librarian->id . ":" . $item1_id . ":confirm1:confirm2" } ); $t->post_ok( "//$userid:$password@/api/v1/checkouts?confirmation=$token" => json => { - item_id => $item2_id, + item_id => $item1_id, patron_id => $patron_id } )->status_is(201)->or( sub { diag $t->tx->res->body } ); @@ -540,40 +540,34 @@ subtest 'delete checkout' => sub { } ); my $unauth_password = 'thePassword000'; - $patron->set_password( - { password => $unauth_password, skip_validattion => 1 } ); + $patron->set_password( { password => $unauth_password, skip_validattion => 1 } ); my $unauth_userid = $patron->userid; - my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); + my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); my $library_id = $branch->id; - my $item1 = $builder->build_sample_item; - my $item1_id = $item1->id; + my $item1 = $builder->build_sample_item; + my $item1_id = $item1->id; - - $t->delete_ok( - "//$unauth_userid:$unauth_password@/api/v1/checkouts" => json => - { item_id => $item1_id, library_id => $library_id } )->status_is(403) - ->json_is( + $t->delete_ok( "//$unauth_userid:$unauth_password@/api/v1/checkouts" => json => + { item_id => $item1_id, library_id => $library_id } )->status_is(403)->json_is( { - error => "Authorization failure. Missing required permission(s).", - required_permissions => - { circulate => "circulate_remaining_permissions" } + error => "Authorization failure. Missing required permission(s).", + required_permissions => { circulate => "circulate_remaining_permissions" } } - ); + ); - $t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json => - { item_id => $item1_id, library_id => $library_id } )->status_is(400) - ->json_is( - '/error' => 'Item not checked out' ); + $t->delete_ok( + "//$userid:$password@/api/v1/checkouts" => json => { item_id => $item1_id, library_id => $library_id } ) + ->status_is(400)->json_is( '/error' => 'Item not checked out' ); AddIssue( $patron->unblessed, $item1->barcode ); - $t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json => - { item_id => $item1_id, library_id => $library_id } )->status_is(201); + $t->delete_ok( + "//$userid:$password@/api/v1/checkouts" => json => { item_id => $item1_id, library_id => $library_id } ) + ->status_is(201); $item1->delete; - $t->delete_ok( "//$userid:$password@/api/v1/checkouts/" => json => - { item_id => $item1_id, library_id => $library_id } )->status_is(409) - ->json_is( - '/error' => 'Item not found' ); + $t->delete_ok( + "//$userid:$password@/api/v1/checkouts/" => json => { item_id => $item1_id, library_id => $library_id } ) + ->status_is(409)->json_is( '/error' => 'Item not found' ); $schema->storage->txn_rollback; }; -- 2.41.0