|
Lines 19-27
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 2; |
22 |
use Test::More tests => 3; |
| 23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
|
|
24 |
use Test::Warn; |
| 24 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
|
|
26 |
use t::lib::TestBuilder; |
| 25 |
|
27 |
|
| 26 |
use MARC::Record; |
28 |
use MARC::Record; |
| 27 |
|
29 |
|
|
Lines 35-43
SKIP: {
Link Here
|
| 35 |
|
37 |
|
| 36 |
eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; }; |
38 |
eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; }; |
| 37 |
|
39 |
|
| 38 |
skip 'Elasticsearch configuration not available', 1 |
40 |
skip 'Elasticsearch configuration not available', 2 |
| 39 |
if $@; |
41 |
if $@; |
| 40 |
|
42 |
|
|
|
43 |
my $builder = t::lib::TestBuilder->new; |
| 44 |
my $biblio = $builder->build_sample_biblio; # create biblio before we start mocking to avoid trouble indexing on creation |
| 45 |
|
| 41 |
subtest 'create_index() tests' => sub { |
46 |
subtest 'create_index() tests' => sub { |
| 42 |
plan tests => 6; |
47 |
plan tests => 6; |
| 43 |
my $se = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch' ); |
48 |
my $se = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch' ); |
|
Lines 81-84
subtest 'create_index() tests' => sub {
Link Here
|
| 81 |
); |
86 |
); |
| 82 |
}; |
87 |
}; |
| 83 |
|
88 |
|
|
|
89 |
subtest 'index_records() tests' => sub { |
| 90 |
plan tests => 2; |
| 91 |
my $mock_index = Test::MockModule->new("Koha::SearchEngine::Elasticsearch::Indexer"); |
| 92 |
$mock_index->mock( update_index => sub { |
| 93 |
my ($self, $record_ids, $records) = @_; |
| 94 |
warn $record_ids->[0] . $records->[0]->as_usmarc; |
| 95 |
}); |
| 96 |
|
| 97 |
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'authorities' }); |
| 98 |
|
| 99 |
my $marc_record = MARC::Record->new(); |
| 100 |
$marc_record->append_fields( |
| 101 |
MARC::Field->new('001', '1234567'), |
| 102 |
MARC::Field->new('100', '', '', 'a' => 'Rosenstock, Jeff'), |
| 103 |
); |
| 104 |
warning_is{ $indexer->index_records([42],'specialUpdate','authorityserver',[$marc_record]); } "42".$marc_record->as_usmarc, |
| 105 |
"When passing record and ids to index_records they are correctly passed through to update_index"; |
| 106 |
|
| 107 |
$indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'biblios' }); |
| 108 |
$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, |
| 110 |
"When passing id only to index_records the marc record is fetched and passed through to update_index"; |
| 111 |
}; |
| 112 |
|
| 84 |
} |
113 |
} |
| 85 |
- |
|
|