Bug 42485: (QA follow-up) Add explicit JSON::PP import and test coverage

Add explicit `use JSON::PP ()` to Elasticsearch.pm and the test file
to make the dependency on JSON::PP::false visible rather than relying
on YAML::XS loading it as a side effect.

Extend the get_elasticsearch_mappings() test subtest to assert that
date_detection and numeric_detection are disabled at the mapping root.

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2026-06-04 16:55:52 +01:00 committed by Lucas Gass
parent 78850b4a15
commit 40b9e8abd5
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 11 additions and 1 deletions

View File

@ -58,6 +58,7 @@ use Search::Elasticsearch::Role::Cxn;
}
use Try::Tiny qw( catch try );
use JSON::PP ();
use YAML::XS;
use List::Util qw( sum0 );

View File

@ -28,6 +28,7 @@ use t::lib::TestBuilder;
use Test::MockModule;
use JSON::PP ();
use MARC::Record;
use Try::Tiny;
use List::Util qw( any );
@ -144,7 +145,7 @@ subtest 'get_elasticsearch_settings() tests' => sub {
subtest 'get_elasticsearch_mappings() tests' => sub {
plan tests => 3;
plan tests => 5;
my $mappings;
@ -206,6 +207,14 @@ subtest 'get_elasticsearch_mappings() tests' => sub {
'Field mappings parsed correctly for sort for callnumber type'
);
is( $mappings->{properties}{isbn__sort}{index}, 'false', 'Field mappings parsed correctly' );
is(
$mappings->{date_detection}, JSON::PP::false,
'date_detection disabled at mapping root'
);
is(
$mappings->{numeric_detection}, JSON::PP::false,
'numeric_detection disabled at mapping root'
);
};