Lines 91-97
subtest 'index_records() tests' => sub {
Link Here
|
91 |
my $mock_index = Test::MockModule->new("Koha::SearchEngine::Elasticsearch::Indexer"); |
91 |
my $mock_index = Test::MockModule->new("Koha::SearchEngine::Elasticsearch::Indexer"); |
92 |
$mock_index->mock( update_index => sub { |
92 |
$mock_index->mock( update_index => sub { |
93 |
my ($self, $record_ids, $records) = @_; |
93 |
my ($self, $record_ids, $records) = @_; |
94 |
warn $record_ids->[0] . $records->[0]->as_usmarc; |
94 |
warn "Update " . $record_ids->[0] . $records->[0]->as_usmarc; |
|
|
95 |
}); |
96 |
$mock_index->mock( update_index_background => sub { |
97 |
my ($self, $record_ids) = @_; |
98 |
warn "Update background " . $record_ids->[0]; |
95 |
}); |
99 |
}); |
96 |
|
100 |
|
97 |
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'authorities' }); |
101 |
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'authorities' }); |
Lines 101-113
subtest 'index_records() tests' => sub {
Link Here
|
101 |
MARC::Field->new('001', '1234567'), |
105 |
MARC::Field->new('001', '1234567'), |
102 |
MARC::Field->new('100', '', '', 'a' => 'Rosenstock, Jeff'), |
106 |
MARC::Field->new('100', '', '', 'a' => 'Rosenstock, Jeff'), |
103 |
); |
107 |
); |
104 |
warning_is{ $indexer->index_records([42],'specialUpdate','authorityserver',[$marc_record]); } "42".$marc_record->as_usmarc, |
108 |
warning_is { |
105 |
"When passing record and ids to index_records they are correctly passed through to update_index"; |
109 |
$indexer->index_records( [42], 'specialUpdate', 'authorityserver', |
|
|
110 |
[$marc_record] ); |
111 |
} |
112 |
"Update 42" . $marc_record->as_usmarc, |
113 |
"When passing record and ids to index_records they are correctly passed through to update_index"; |
106 |
|
114 |
|
107 |
$indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'biblios' }); |
115 |
$indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'biblios' }); |
108 |
$marc_record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber, embed_items => 1 }); |
116 |
$marc_record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber, embed_items => 1 }); |
109 |
warning_is{ $indexer->index_records([$biblio->biblionumber],'specialUpdate','biblioserver'); } $biblio->biblionumber.$marc_record->as_usmarc, |
117 |
warning_is { |
110 |
"When passing id only to index_records the marc record is fetched and passed through to update_index"; |
118 |
$indexer->index_records( [ $biblio->biblionumber ], |
|
|
119 |
'specialUpdate', 'biblioserver' ); |
120 |
} |
121 |
"Update background " . $biblio->biblionumber, |
122 |
"When passing id only to index_records the marc record is fetched and passed through to update_index"; |
111 |
}; |
123 |
}; |
112 |
|
124 |
|
113 |
} |
125 |
} |
114 |
- |
|
|