Lines 1-6
Link Here
|
1 |
# Copyright 2015 Catalyst IT |
1 |
# Copyright 2015 Catalyst IT |
2 |
# |
2 |
# |
3 |
# |
|
|
4 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
5 |
# |
4 |
# |
6 |
# Koha is free software; you can redistribute it and/or modify it |
5 |
# Koha is free software; you can redistribute it and/or modify it |
Lines 16-47
Link Here
|
16 |
# You should have received a copy of the GNU General Public License |
15 |
# You should have received a copy of the GNU General Public License |
17 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
|
17 |
|
19 |
use strict; |
18 |
use Modern::Perl; |
20 |
use warnings; |
19 |
|
|
|
20 |
use Test::More tests => 5; |
21 |
|
21 |
|
22 |
use Test::More tests => 5; # last test to print |
|
|
23 |
use MARC::Record; |
22 |
use MARC::Record; |
24 |
|
23 |
|
25 |
use_ok('Koha::ElasticSearch::Indexer'); |
24 |
use_ok('Koha::ElasticSearch::Indexer'); |
26 |
|
25 |
|
27 |
my $indexer; |
26 |
my $indexer; |
28 |
ok( |
27 |
ok( |
29 |
$indexer = Koha::ElasticSearch::Indexer->new( |
28 |
$indexer = Koha::ElasticSearch::Indexer->new({ 'index' => 'biblio' }), |
30 |
{ |
|
|
31 |
'nodes' => ['localhost:9200'], |
32 |
'index' => 'mydb' |
33 |
} |
34 |
), |
35 |
'Creating new indexer object' |
29 |
'Creating new indexer object' |
36 |
); |
30 |
); |
37 |
|
31 |
|
38 |
my $marc_record = MARC::Record->new(); |
32 |
my $marc_record = MARC::Record->new(); |
39 |
my $field = MARC::Field->new( '001', '1234567' ); |
33 |
$marc_record->append_fields( |
40 |
$marc_record->append_fields($field); |
34 |
MARC::Field->new( '001', '1234567' ), |
41 |
$field = MARC::Field->new( '020', '', '', 'a' => '1234567890123' ); |
35 |
MARC::Field->new( '020', '', '', 'a' => '1234567890123' ), |
42 |
$marc_record->append_fields($field); |
36 |
MARC::Field->new( '245', '', '', 'a' => 'Title' ) |
43 |
$field = MARC::Field->new( '245', '', '', 'a' => 'Title' ); |
37 |
); |
44 |
$marc_record->append_fields($field); |
|
|
45 |
|
38 |
|
46 |
my $records = [$marc_record]; |
39 |
my $records = [$marc_record]; |
47 |
ok( my $converted = $indexer->_convert_marc_to_json($records), |
40 |
ok( my $converted = $indexer->_convert_marc_to_json($records), |
Lines 49-52
ok( my $converted = $indexer->_convert_marc_to_json($records),
Link Here
|
49 |
|
42 |
|
50 |
is( $converted->count, 1, 'One converted record' ); |
43 |
is( $converted->count, 1, 'One converted record' ); |
51 |
|
44 |
|
52 |
ok( $indexer->update_index(undef,$records), 'Update Index' ); |
45 |
SKIP: { |
|
|
46 |
|
47 |
eval { $indexer->get_elasticsearch_params; }; |
48 |
|
49 |
skip 'ElasticSeatch configuration not available', 1 |
50 |
if $@; |
51 |
|
52 |
ok( $indexer->update_index(undef,$records), 'Update Index' ); |
53 |
} |
54 |
|
55 |
1; |