Bug 33406: (QA follow-up) Adjust tests and tidy
Rather than test that nothing is returned, we want to test that the terms are filtered as expected. This also avoids the possibility of the tests failing in a db where there is a record for Donald Duck
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 3d7b60dc90
)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
14487cd5e0
commit
4cc4120322
2 changed files with 9 additions and 14 deletions
|
@ -97,25 +97,19 @@ if ( $op eq "do_search" ) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
my $builder = Koha::SearchEngine::QueryBuilder->new(
|
my $builder = Koha::SearchEngine::QueryBuilder->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
|
||||||
{ index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
|
my $searcher = Koha::SearchEngine::Search->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
|
||||||
my $searcher = Koha::SearchEngine::Search->new(
|
|
||||||
{ index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
|
|
||||||
|
|
||||||
my $search_query = $builder->build_authorities_query_compat(
|
my $search_query = $builder->build_authorities_query_compat(
|
||||||
[$marclist], [$and_or], [$excluding], [$operator],
|
[$marclist], [$and_or], [$excluding], [$operator],
|
||||||
[$value], $authtypecode, $orderby
|
[$value], $authtypecode, $orderby
|
||||||
);
|
);
|
||||||
my ( $results, $total );
|
my ( $results, $total );
|
||||||
eval {
|
eval { ( $results, $total ) = $searcher->search_auth_compat( $search_query, $offset, $resultsperpage ); };
|
||||||
( $results, $total ) = $searcher->search_auth_compat(
|
|
||||||
$search_query, $offset, $resultsperpage
|
|
||||||
);
|
|
||||||
};
|
|
||||||
if ($@) {
|
if ($@) {
|
||||||
my $query_error = q{};
|
my $query_error = q{};
|
||||||
$query_error .= $@ if $@;
|
$query_error .= $@ if $@;
|
||||||
$template->param(query_error => $query_error);
|
$template->param( query_error => $query_error );
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->param( search_query => $search_query ) if C4::Context->preference('DumpSearchQueryTemplate');
|
$template->param( search_query => $search_query ) if C4::Context->preference('DumpSearchQueryTemplate');
|
||||||
|
|
|
@ -45,12 +45,13 @@ subtest 'search_auth_compat' => sub {
|
||||||
|
|
||||||
my $search_query = $builder->build_authorities_query_compat(
|
my $search_query = $builder->build_authorities_query_compat(
|
||||||
['mainmainentry'], ['and'], [''], ['contains'],
|
['mainmainentry'], ['and'], [''], ['contains'],
|
||||||
['Donald - Duck'], '', 'HeadingAsc'
|
['Donald - ^ \ ~ + Duck'], '', 'HeadingAsc'
|
||||||
);
|
);
|
||||||
|
|
||||||
my ( $bad_results, undef ) = $search->search_auth_compat( $search_query, 0, 20, undef );
|
is(
|
||||||
|
$search_query->{query}->{bool}->{must}->[0]->{query_string}->{query}, '(Donald*) AND (Duck*)',
|
||||||
is( @$bad_results[0], undef, 'We expect no record because it doesnt exist' );
|
"Reserved characters -, ^, \\, ~, + have been removed from search query"
|
||||||
|
);
|
||||||
|
|
||||||
my $module = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search');
|
my $module = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search');
|
||||||
$module->mock( 'count_auth_use', sub { return 1 } );
|
$module->mock( 'count_auth_use', sub { return 1 } );
|
||||||
|
|
Loading…
Reference in a new issue