Bug 37898: Wrap some ERM api tests inside a transaction

Trivial ones.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Tomas Cohen Arazi 2024-09-11 14:48:34 -03:00 committed by Martin Renvoize
parent 979d1cb2c5
commit 7cd31e98e0
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 12 additions and 0 deletions

View File

@ -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;
};

View File

@ -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;
};