1 # Copyright 2015 Catalyst IT
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test::More tests => 2;
28 my $schema = Koha::Database->schema();
30 use_ok('Koha::SearchEngine::Elasticsearch::Indexer');
32 subtest 'create_index() tests' => sub {
34 my $se = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch' );
35 $se->mock( 'get_elasticsearch_params', sub {
36 my ($self, $sub ) = @_;
37 my $method = $se->original( 'get_elasticsearch_params' );
38 my $params = $method->( $self );
39 $params->{index_name} .= '__test';
45 $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'biblios' }),
46 'Creating a new indexer object'
50 $indexer->create_index(),
51 Koha::SearchEngine::Elasticsearch::Indexer::INDEX_STATUS_OK(),
55 my $marc_record = MARC::Record->new();
56 $marc_record->append_fields(
57 MARC::Field->new('001', '1234567'),
58 MARC::Field->new('020', '', '', 'a' => '1234567890123'),
59 MARC::Field->new('245', '', '', 'a' => 'Title')
61 my $records = [$marc_record];
62 ok($indexer->update_index(undef, $records), 'Update Index');
65 $indexer->drop_index(),
66 Koha::SearchEngine::Elasticsearch::Indexer::INDEX_STATUS_RECREATE_REQUIRED(),