From 7cd31e98e0abca0638604ecc6d0d17abbe34afd0 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 11 Sep 2024 14:48:34 -0300 Subject: [PATCH] Bug 37898: Wrap some ERM api tests inside a transaction Trivial ones. Signed-off-by: Martin Renvoize --- t/db_dependent/api/v1/erm_counter_registries.t | 6 ++++++ t/db_dependent/api/v1/erm_sushi_services.t | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/t/db_dependent/api/v1/erm_counter_registries.t b/t/db_dependent/api/v1/erm_counter_registries.t index 894fa76dc0..ed7c030ae6 100755 --- a/t/db_dependent/api/v1/erm_counter_registries.t +++ b/t/db_dependent/api/v1/erm_counter_registries.t @@ -34,14 +34,18 @@ use Koha::Database; # The Usage statistics module uses an external API to fetch data from the counter registry # This test is designed to catch any changes in the response that the API provides so that we can react quickly to ensure the module still functions as expected +my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; my $t = Test::Mojo->new('Koha::REST::V1'); t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); subtest 'get() tests' => sub { + plan tests => 5; + $schema->storage->txn_begin; + my @expected_fields = ( "abbrev", "address", @@ -90,4 +94,6 @@ subtest 'get() tests' => sub { my @new_fields_in_response = array_minus( @response_fields, @expected_fields ); is( scalar(@new_fields_in_response), 0, 'The response fields match the expected fields' ); + + $schema->storage->txn_rollback; }; diff --git a/t/db_dependent/api/v1/erm_sushi_services.t b/t/db_dependent/api/v1/erm_sushi_services.t index 097dfc7f73..a6e712138f 100755 --- a/t/db_dependent/api/v1/erm_sushi_services.t +++ b/t/db_dependent/api/v1/erm_sushi_services.t @@ -31,6 +31,7 @@ use Array::Utils qw( array_minus ); use Koha::ERM::EUsage::CounterFiles; use Koha::Database; +my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; my $t = Test::Mojo->new('Koha::REST::V1'); @@ -40,8 +41,11 @@ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); # This test is designed to catch any changes in the response that the API provides so that we can react quickly to ensure the module still functions as expected subtest 'get() tests' => sub { + plan tests => 5; + $schema->storage->txn_begin; + my $service_url = "https://registry.countermetrics.org/api/v1/sushi-service/b94bc981-fa16-4bf6-ba5f-6c113f7ffa0b/"; my @expected_fields = ( "api_key_info", @@ -100,4 +104,6 @@ subtest 'get() tests' => sub { my @new_fields_in_response = array_minus( @response_fields, @expected_fields ); is( scalar(@new_fields_in_response), 0, 'The response fields match the expected fields' ); + + $schema->storage->txn_rollback; }; -- 2.39.5