Bugzilla – Attachment 157283 Details for
Bug 17897
Koha::SearchMappingManager - Simplify search mapping modifications
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17897: (follow-up) Cleanup after tests
Bug-17897-follow-up-Cleanup-after-tests.patch (text/plain), 3.29 KB, created by
David Nind
on 2023-10-17 19:33:40 UTC
(
hide
)
Description:
Bug 17897: (follow-up) Cleanup after tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-10-17 19:33:40 UTC
Size:
3.29 KB
patch
obsolete
>From f5a5e75bd600512b39ff4cb0ec4835f7439a8680 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Tue, 1 Aug 2017 15:26:20 +0300 >Subject: [PATCH] Bug 17897: (follow-up) Cleanup after tests > >Adds rollback to test data in t/db_dependent/Koha/SearchEngine/ElasticSearch.t > >To test: >1. prove t/db_dependent/Koha/SearchEngine/ElasticSearch.t > >Rebased-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Koha/SearchEngine/ElasticSearch.t | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/SearchEngine/ElasticSearch.t b/t/db_dependent/Koha/SearchEngine/ElasticSearch.t >index 9f14548872..77c9237c13 100644 >--- a/t/db_dependent/Koha/SearchEngine/ElasticSearch.t >+++ b/t/db_dependent/Koha/SearchEngine/ElasticSearch.t >@@ -21,14 +21,18 @@ use Modern::Perl qw(2014); > use utf8; > use Test::More; > >+use Koha::Database; > use Koha::SearchEngine::Elasticsearch; > use Koha::SearchMappingManager; > >+my $schema = Koha::Database->schema; > > subtest "Reset Elasticsearch mappings", \&reset_elasticsearch_mappings; > sub reset_elasticsearch_mappings { > my ($rv, $mappings, $count, $mapping); > >+ $schema->storage->txn_begin; >+ > ok(1, 'Scenario: Reset Elasticsearch mappings to an empty database'); > #There might or might not be any mappings. Whatever the initial status is, make sure we start from empty tables > $rv = Koha::SearchMappingManager::flush(); >@@ -69,12 +73,16 @@ sub reset_elasticsearch_mappings { > $mappings = Koha::SearchMappingManager::get_search_mappings({index_name => 'biblios'}); > $count = $mappings->count(); > ok($count > 10, 'Then search mapping tables have been populated'); >+ >+ $schema->storage->txn_rollback; > } > > subtest "Get Elasticsearch mappings", \&get_search_mappings; > sub get_search_mappings { > my ($mappings, $mapping); > >+ $schema->storage->txn_begin; >+ > ok(1, 'Scenario: Get a single search mapping by name'); > $mappings = Koha::SearchMappingManager::get_search_mappings({index_name => 'biblios', name => 'ff7-00'}); > ok($mappings, 'When a search mappings is fetched'); >@@ -91,13 +99,17 @@ sub get_search_mappings { > ok(1, 'Scenario: Get all search mappings'); > $mappings = Koha::SearchMappingManager::get_search_mappings({index_name => 'biblios'}); > ok($mappings, 'When search mappings are fetched'); >- ok($mappings->count() > 10, 'Then we have "'.$mappings->count().'" search mappings :)') >+ ok($mappings->count() > 10, 'Then we have "'.$mappings->count().'" search mappings :)'); >+ >+ $schema->storage->txn_rollback; > } > > subtest "Add a search mapping", \&add_mapping; > sub add_mapping { > my ($rv, $mappings, $mapping, $count); > >+ $schema->storage->txn_begin; >+ > ok(1, "Scenario: Add the same mapping twice and hope for no duplicate mappings"); > $rv = Koha::SearchMappingManager::add_mapping({name => 'ln-test', > label => 'original language', >@@ -122,6 +134,8 @@ sub add_mapping { > $mappings = Koha::SearchMappingManager::get_search_mappings({index_name => 'biblios', name => 'ln-test'}); > $count = $mappings->count(); > is($count, 1, "Then we received only one mapping from the database"); >+ >+ $schema->storage->txn_rollback; > } > > done_testing; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17897
:
58942
|
65392
|
102475
|
102476
|
115320
|
115321
|
115322
|
143744
|
157224
|
157282
|
157283
|
157284
|
158487
|
158488
|
158489
|
158490
|
158491
|
158492
|
158561
|
158562
|
158563
|
158564