1 # Copyright 2015 Catalyst IT
4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Test::More tests => 5; # last test to print
25 use_ok('Koha::ElasticSearch::Indexer');
29 $indexer = Koha::ElasticSearch::Indexer->new(
31 'nodes' => ['localhost:9200'],
35 'Creating new indexer object'
38 my $marc_record = MARC::Record->new();
39 my $field = MARC::Field->new( '001', '1234567' );
40 $marc_record->append_fields($field);
41 $field = MARC::Field->new( '020', '', '', 'a' => '1234567890123' );
42 $marc_record->append_fields($field);
43 $field = MARC::Field->new( '245', '', '', 'a' => 'Title' );
44 $marc_record->append_fields($field);
46 my $records = [$marc_record];
47 ok( my $converted = $indexer->_convert_marc_to_json($records),
48 'Convert some records' );
50 is( $converted->count, 1, 'One converted record' );
52 ok( $indexer->update_index(undef,$records), 'Update Index' );