Bug 41710: Correctly run tests SearchEngine/Elasticsearch/Search.t in a txn

Test plan:
0. Apply this patch and startup ktd with elastic (e.g `--search-engine es7`)
1. prove t/db_dependent/check_sysprefs.t
=> pass
2. DB cli> SELECT COUNT(*) FROM systempreferences;
3. prove t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t
4. DB cli> SELECT COUNT(*) FROM systempreferences;
=> No change, still the same number of sysprefs
5. prove t/db_dependent/check_sysprefs.t
=> pass
6. Revert this patch or checkout main
7. prove t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t
8. DB cli> SELECT COUNT(*) FROM systempreferences;
=> One syspref crated (ElasticsearchIndexStatus_mydb)
9. prove t/db_dependent/check_sysprefs.t
=> fail

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 5f9ec5e5c0)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-01-26 11:09:33 +01:00 committed by Jacob O'Mara
parent 24ed8c2b0c
commit 3b3e7ee90c
No known key found for this signature in database
1 changed files with 3 additions and 1 deletions

View File

@ -26,6 +26,9 @@ use Koha::SearchEngine::Elasticsearch::QueryBuilder;
use Koha::SearchEngine::Elasticsearch::Indexer;
use Koha::SearchFields;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin;
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch');
$se->mock(
'get_elasticsearch_mappings',
@ -123,7 +126,6 @@ SKIP: {
subtest "_convert_facets" => sub {
plan tests => 5;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;