From 7114147cf6d4f4e50e96ca5547417c0f8c575ade Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 20 Oct 2025 12:01:24 +0200 Subject: [PATCH] Bug 39320: (follow-up) Add counts API tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent tests to fail if data in DB Signed-off-by: Tomás Cohen Arazi --- t/db_dependent/api/v1/erm_counts.t | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/api/v1/erm_counts.t b/t/db_dependent/api/v1/erm_counts.t index 920242920a4..ec0f5c454f1 100755 --- a/t/db_dependent/api/v1/erm_counts.t +++ b/t/db_dependent/api/v1/erm_counts.t @@ -24,6 +24,13 @@ use Test::Mojo; use t::lib::TestBuilder; use t::lib::Mocks; +use Koha::ERM::Agreements; +use Koha::ERM::Documents; +use Koha::ERM::EHoldings::Packages; +use Koha::ERM::EHoldings::Titles; +use Koha::ERM::Licenses; +use Koha::ERM::EUsage::UsageDataProviders; + use Koha::Database; my $schema = Koha::Database->new->schema; @@ -37,6 +44,13 @@ subtest 'count() tests' => sub { $schema->storage->txn_begin; + Koha::ERM::Agreements->search->delete; + Koha::ERM::Documents->search->delete; + Koha::ERM::EHoldings::Packages->search->delete; + Koha::ERM::EHoldings::Titles->search->delete; + Koha::ERM::Licenses->search->delete; + Koha::ERM::EUsage::UsageDataProviders->search->delete; + my $librarian = $builder->build_object( { class => 'Koha::Patrons', @@ -64,8 +78,12 @@ subtest 'count() tests' => sub { $t->get_ok("//$userid:$password@/api/v1/erm/counts")->status_is(200)->json_is( { counts => { - agreements_count => 1, documents_count => 0, eholdings_packages_count => 0, - eholdings_titles_count => 0, licenses_count => 1, usage_data_providers_count => 0 + agreements_count => 1, + documents_count => 0, + eholdings_packages_count => 0, + eholdings_titles_count => 0, + licenses_count => 1, + usage_data_providers_count => 0 } } ); -- 2.51.2