+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";
+};
+