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

(-)a/t/db_dependent/Koha/SearchEngine/ElasticSearch.t (-9 / +5 lines)
Lines 26-37 use Koha::SearchEngine::Elasticsearch; Link Here
26
use Koha::SearchMappingManager;
26
use Koha::SearchMappingManager;
27
27
28
my $schema = Koha::Database->schema;
28
my $schema = Koha::Database->schema;
29
$schema->storage->txn_begin;
29
30
30
subtest "Reset Elasticsearch mappings", \&reset_elasticsearch_mappings;
31
subtest "Reset Elasticsearch mappings", \&reset_elasticsearch_mappings;
31
sub reset_elasticsearch_mappings {
32
sub reset_elasticsearch_mappings {
32
    my ($rv, $mappings, $count, $mapping);
33
    my ($rv, $mappings, $count, $mapping);
33
34
34
    $schema->storage->txn_begin;
35
    
35
36
36
    ok(1, 'Scenario: Reset Elasticsearch mappings to an empty database');
37
    ok(1, 'Scenario: Reset Elasticsearch mappings to an empty database');
37
    #There might or might not be any mappings. Whatever the initial status is, make sure we start from empty tables
38
    #There might or might not be any mappings. Whatever the initial status is, make sure we start from empty tables
Lines 74-88 sub reset_elasticsearch_mappings { Link Here
74
    $count = $mappings->count();
75
    $count = $mappings->count();
75
    ok($count > 10, 'Then search mapping tables have been populated');
76
    ok($count > 10, 'Then search mapping tables have been populated');
76
77
77
    $schema->storage->txn_rollback;
78
}
78
}
79
79
80
subtest "Get Elasticsearch mappings", \&get_search_mappings;
80
subtest "Get Elasticsearch mappings", \&get_search_mappings;
81
sub get_search_mappings {
81
sub get_search_mappings {
82
    my ($mappings, $mapping);
82
    my ($mappings, $mapping);
83
83
84
    $schema->storage->txn_begin;
85
86
    ok(1, 'Scenario: Get a single search mapping by name');
84
    ok(1, 'Scenario: Get a single search mapping by name');
87
    $mappings = Koha::SearchMappingManager::get_search_mappings({index_name => 'biblios', name => 'ff7-00'});
85
    $mappings = Koha::SearchMappingManager::get_search_mappings({index_name => 'biblios', name => 'ff7-00'});
88
    ok($mappings, 'When a search mappings is fetched');
86
    ok($mappings, 'When a search mappings is fetched');
Lines 101-115 sub get_search_mappings { Link Here
101
    ok($mappings, 'When search mappings are fetched');
99
    ok($mappings, 'When search mappings are fetched');
102
    ok($mappings->count() > 10, 'Then we have "'.$mappings->count().'" search mappings :)');
100
    ok($mappings->count() > 10, 'Then we have "'.$mappings->count().'" search mappings :)');
103
101
104
    $schema->storage->txn_rollback;
105
}
102
}
106
103
107
subtest "Add a search mapping", \&add_mapping;
104
subtest "Add a search mapping", \&add_mapping;
108
sub add_mapping {
105
sub add_mapping {
109
    my ($rv, $mappings, $mapping, $count);
106
    my ($rv, $mappings, $mapping, $count);
110
107
111
    $schema->storage->txn_begin;
112
113
    ok(1, "Scenario: Add the same mapping twice and hope for no duplicate mappings");
108
    ok(1, "Scenario: Add the same mapping twice and hope for no duplicate mappings");
114
    $rv = Koha::SearchMappingManager::add_mapping({name => 'ln-test',
109
    $rv = Koha::SearchMappingManager::add_mapping({name => 'ln-test',
115
                                                   label => 'original language',
110
                                                   label => 'original language',
Lines 135-141 sub add_mapping { Link Here
135
    $count = $mappings->count();
130
    $count = $mappings->count();
136
    is($count, 1, "Then we received only one mapping from the database");
131
    is($count, 1, "Then we received only one mapping from the database");
137
132
138
    $schema->storage->txn_rollback;
133
    
139
}
134
}
140
135
136
$schema->storage->txn_rollback;
137
141
done_testing;
138
done_testing;
142
- 

Return to bug 17897