Bugzilla – Attachment 113664 Details for
Bug 26903
Authority records not being indexed in Elasticsearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26903: Unit tests
Bug-26903-Unit-tests.patch (text/plain), 2.82 KB, created by
Martin Renvoize (ashimema)
on 2020-11-16 13:35:40 UTC
(
hide
)
Description:
Bug 26903: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-11-16 13:35:40 UTC
Size:
2.82 KB
patch
obsolete
>From 17f2a97d34d7169015c1985cf32e9b276555fc89 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 13 Nov 2020 16:33:12 +0000 >Subject: [PATCH] Bug 26903: Unit tests > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../Koha/SearchEngine/Elasticsearch/Indexer.t | 33 +++++++++++++++++-- > 1 file changed, 31 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Indexer.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Indexer.t >index 546f9266de..42e9266c9b 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Indexer.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Indexer.t >@@ -19,9 +19,11 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::MockModule; >+use Test::Warn; > use t::lib::Mocks; >+use t::lib::TestBuilder; > > use MARC::Record; > >@@ -35,9 +37,12 @@ SKIP: { > > eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; }; > >- skip 'Elasticsearch configuration not available', 1 >+ skip 'Elasticsearch configuration not available', 2 > if $@; > >+my $builder = t::lib::TestBuilder->new; >+my $biblio = $builder->build_sample_biblio; # create biblio before we start mocking to avoid trouble indexing on creation >+ > subtest 'create_index() tests' => sub { > plan tests => 6; > my $se = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch' ); >@@ -81,4 +86,28 @@ subtest 'create_index() tests' => sub { > ); > }; > >+subtest 'index_records() tests' => sub { >+ plan tests => 2; >+ my $mock_index = Test::MockModule->new("Koha::SearchEngine::Elasticsearch::Indexer"); >+ $mock_index->mock( update_index => sub { >+ my ($self, $record_ids, $records) = @_; >+ warn $record_ids->[0] . $records->[0]->as_usmarc; >+ }); >+ >+ my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'authorities' }); >+ >+ my $marc_record = MARC::Record->new(); >+ $marc_record->append_fields( >+ MARC::Field->new('001', '1234567'), >+ MARC::Field->new('100', '', '', 'a' => 'Rosenstock, Jeff'), >+ ); >+ warning_is{ $indexer->index_records([42],'specialUpdate','authorityserver',[$marc_record]); } "42".$marc_record->as_usmarc, >+ "When passing record and ids to index_records they are correctly passed through to update_index"; >+ >+ $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'biblios' }); >+ $marc_record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber, embed_items => 1 }); >+ warning_is{ $indexer->index_records([$biblio->biblionumber],'specialUpdate','biblioserver'); } $biblio->biblionumber.$marc_record->as_usmarc, >+ "When passing id only to index_records the marc record is fetched and passed through to update_index"; >+}; >+ > } >-- >2.20.1
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 26903
:
113613
|
113614
|
113644
|
113645
| 113664 |
113665
|
114299