From 46b2b35ef864dc8cb06f3e581c1a9b783ad3bb89 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 20 Jan 2025 10:05:56 -0300 Subject: [PATCH] Bug 38926: Regression tests --- t/db_dependent/api/v1/biblios.t | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t index c10bae833e4..c44509033e7 100755 --- a/t/db_dependent/api/v1/biblios.t +++ b/t/db_dependent/api/v1/biblios.t @@ -899,9 +899,9 @@ subtest 'set_rating() tests' => sub { }; -subtest 'post() tests' => sub { +subtest 'add() tests' => sub { - plan tests => 14; + plan tests => 17; $schema->storage->txn_begin; @@ -1358,6 +1358,22 @@ subtest 'post() tests' => sub { )->status_is(200); }; + my $mock_biblio = Test::MockModule->new('C4::Biblio'); + + # FIXME: AddBiblio wraps everything inside a transaction and a try/catch block + # this will need a tweak if this behavior changes + $mock_biblio->mock( 'AddBiblio', sub { return ( undef, undef ); } ); + + $t->post_ok( "//$userid:$password@/api/v1/biblios" => + { 'Content-Type' => 'application/marc', 'x-framework-id' => $frameworkcode } => $marc ) + ->status_is(400) + ->json_is( + { + error => 'Error creating record', + error_code => 'record_creation_failed' + } + ); + $schema->storage->txn_rollback; }; -- 2.48.1