Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 3; |
20 |
use Test::More tests => 2; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use t::lib::Mocks; |
22 |
use t::lib::Mocks; |
23 |
|
23 |
|
Lines 30-36
my $schema = Koha::Database->schema();
Link Here
|
30 |
use_ok('Koha::SearchEngine::Elasticsearch::Indexer'); |
30 |
use_ok('Koha::SearchEngine::Elasticsearch::Indexer'); |
31 |
|
31 |
|
32 |
subtest 'create_index() tests' => sub { |
32 |
subtest 'create_index() tests' => sub { |
33 |
plan tests => 5; |
33 |
plan tests => 6; |
34 |
my $se = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch' ); |
34 |
my $se = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch' ); |
35 |
$se->mock( '_read_configuration', sub { |
35 |
$se->mock( '_read_configuration', sub { |
36 |
my ($self, $sub ) = @_; |
36 |
my ($self, $sub ) = @_; |
Lines 63-68
subtest 'create_index() tests' => sub {
Link Here
|
63 |
my $response = $indexer->update_index([1], $records); |
63 |
my $response = $indexer->update_index([1], $records); |
64 |
is( $response->{errors}, 0, "no error on update_index" ); |
64 |
is( $response->{errors}, 0, "no error on update_index" ); |
65 |
is( scalar(@{$response->{items}}), 1, "1 item indexed" ); |
65 |
is( scalar(@{$response->{items}}), 1, "1 item indexed" ); |
|
|
66 |
is( $response->{items}[0]->{index}->{_id},"1", "We should get a string matching the bibnumber passed in"); |
66 |
|
67 |
|
67 |
is( |
68 |
is( |
68 |
$indexer->drop_index(), |
69 |
$indexer->drop_index(), |
Lines 70-98
subtest 'create_index() tests' => sub {
Link Here
|
70 |
'Dropping the index' |
71 |
'Dropping the index' |
71 |
); |
72 |
); |
72 |
}; |
73 |
}; |
73 |
|
|
|
74 |
|
75 |
subtest 'update_index() tests' => sub { |
76 |
plan tests => 2; |
77 |
my $kse = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch' ); |
78 |
$kse->mock( 'marc_records_to_documents', sub { |
79 |
my ($self, $params ) = @_; |
80 |
return [1]; |
81 |
}); |
82 |
|
83 |
my $indexer; |
84 |
ok( |
85 |
$indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'biblios' }), |
86 |
'Creating a new indexer object' |
87 |
); |
88 |
|
89 |
my $searcher = $indexer->get_elasticsearch(); |
90 |
my $se = Test::MockModule->new( ref $searcher ); |
91 |
$se->mock( 'bulk', sub { |
92 |
my ($self, %params ) = @_; |
93 |
return $params{body}; |
94 |
}); |
95 |
|
96 |
my $bibnumber_array = $indexer->update_index([13],["faked"]); |
97 |
is( $bibnumber_array->[0]->{index}->{_id},"13", "We should get a string matching the bibnumber"); |
98 |
}; |
99 |
- |