Bug 12478: Take the FacetMaxCount pref into account
[koha.git] / t / Koha_ElasticSearch_Indexer.t
1 #
2 #===============================================================================
3 #
4 #         FILE: Koha_ElasticSearch_Indexer.t
5 #
6 #  DESCRIPTION:
7 #
8 #        FILES: ---
9 #         BUGS: ---
10 #        NOTES: ---
11 #       AUTHOR: Chris Cormack (rangi), chrisc@catalyst.net.nz
12 # ORGANIZATION: Koha Development Team
13 #      VERSION: 1.0
14 #      CREATED: 09/12/13 08:57:25
15 #     REVISION: ---
16 #===============================================================================
17
18 use strict;
19 use warnings;
20
21 use Test::More tests => 5;    # last test to print
22 use MARC::Record;
23
24 use_ok('Koha::ElasticSearch::Indexer');
25
26 my $indexer;
27 ok(
28     my $indexer = Koha::ElasticSearch::Indexer->new(
29         {
30             'nodes' => ['localhost:9200'],
31             'index' => 'mydb'
32         }
33     ),
34     'Creating new indexer object'
35 );
36
37 my $marc_record = MARC::Record->new();
38 my $field = MARC::Field->new( '001', '1234567' );
39 $marc_record->append_fields($field);
40 $field = MARC::Field->new( '020', '', '', 'a' => '1234567890123' );
41 $marc_record->append_fields($field);
42 $field = MARC::Field->new( '245', '', '', 'a' => 'Title' );
43 $marc_record->append_fields($field);
44
45 my $records = [$marc_record];
46 ok( my $converted = $indexer->convert_marc_to_json($records),
47     'Convert some records' );
48
49 is( $converted->count, 1, 'One converted record' );
50
51 ok( $indexer->update_index($records), 'Update Index' );