View | Details | Raw Unified | Return to bug 16453
Collapse All | Expand All

(-)a/t/db_dependent/Koha_ElasticSearch_Indexer.t (-17 / +20 lines)
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;
(-)a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t (-10 / +21 lines)
Lines 14-23 Link Here
14
#
14
#
15
# 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
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
use strict;
18
use warnings;
19
17
20
use Test::More tests => 10;    # last test to print
18
use Modern::Perl;
19
20
use Test::More tests => 10;
21
21
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
22
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
22
23
23
my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new( { index => 'mydb' } );
24
my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new( { index => 'mydb' } );
Lines 35-48 is( $searcher->index, 'mydb', 'Testing basic accessor' ); Link Here
35
36
36
ok( my $query = $builder->build_query('easy'), 'Build a search query');
37
ok( my $query = $builder->build_query('easy'), 'Build a search query');
37
38
38
ok( my $results = $searcher->search( $query) , 'Do a search ' );
39
SKIP: {
40
41
    eval { $builder->get_elasticsearch_params; };
42
43
    skip 'ElasticSeatch configuration not available', 6
44
        if $@;
45
46
    ok( my $results = $searcher->search( $query) , 'Do a search ' );
47
48
    ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC');
49
50
    is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results ');
39
51
40
ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC');
52
    ok ($results = $searcher->search_compat( $query ), 'Test search_compat' );
41
53
42
is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results ');
54
    ok (($results,$count) = $searcher->search_auth_compat ( $query ), 'Test search_auth_compat' );
43
55
44
ok ($results = $searcher->search_compat( $query ), 'Test search_compat' );
56
    is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use');
45
57
46
ok (($results,$count) = $searcher->search_auth_compat ( $query ), 'Test search_auth_compat' );
58
}
47
59
48
is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use');
60
1;
49
- 

Return to bug 16453