From ebd22fe738efb5a8ddae4400f220cfaf475d3765 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 15 Jul 2025 12:26:28 +0200 Subject: [PATCH] Bug 40378: Remove warnings from api/v1/biblios.t Content-Type: text/plain; charset=utf-8 t/db_dependent/api/v1/biblios.t .. 12/15 DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry 'cZt7U7mP0KD' for key 'itembarcodeidx' at /kohadevbox/koha/Koha/Obj ect.pm line 174 t/db_dependent/api/v1/biblios.t .. 13/15 DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry 'N44vCoe4tX41' for key 'itembarcodeidx' at /kohadevbox/koha/Koha/Ob ject.pm line 174 Signed-off-by: David Nind Signed-off-by: Marcel de Rooy --- t/db_dependent/api/v1/biblios.t | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t index b3a457b269..e337c37604 100755 --- a/t/db_dependent/api/v1/biblios.t +++ b/t/db_dependent/api/v1/biblios.t @@ -20,7 +20,8 @@ use Modern::Perl; use utf8; use Encode; -use Test::More tests => 15; +use Test::More tests => 16; +use Test::NoWarnings; use Test::MockModule; use Test::Mojo; use Test::Warn; @@ -1889,7 +1890,7 @@ subtest 'list() tests' => sub { subtest 'add_item() tests' => sub { - plan tests => 8; + plan tests => 10; $schema->storage->txn_begin; @@ -1939,17 +1940,20 @@ subtest 'add_item() tests' => sub { my $item = $builder->build_sample_item(); - $t->post_ok( - "//$userid:$password@/api/v1/biblios/$biblio_id/items" => json => { - external_id => $item->barcode, - } - )->status_is( 409, 'Duplicate barcode' ); + warnings_like { + $t->post_ok( + "//$userid:$password@/api/v1/biblios/$biblio_id/items" => json => { + external_id => $item->barcode, + } + )->status_is( 409, 'Duplicate barcode' )->json_is( "/error" => "Duplicate barcode." ); + } + qr{DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(.*\.?)itembarcodeidx'}; $schema->storage->txn_rollback; }; subtest 'update_item() tests' => sub { - plan tests => 7; + plan tests => 9; $schema->storage->txn_begin; @@ -1993,11 +1997,14 @@ subtest 'update_item() tests' => sub { my $other_item = $builder->build_sample_item(); - $t->put_ok( - "//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { - external_id => $other_item->barcode, - } - )->status_is( 409, 'Barcode not unique' ); + warnings_like { + $t->put_ok( + "//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { + external_id => $other_item->barcode, + } + )->status_is( 409, 'Barcode not unique' )->json_is( "/error" => "Duplicate barcode." ); + } + qr{DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(.*\.?)itembarcodeidx'}; $t->put_ok( "//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { -- 2.39.5