Rather than rely on eval(), Jonathan Druart recommended in
comment #6 to use Use Module::Load::Conditional::can_load.
This addresses that concern.
TEST PLAN
---------
$ git fetch
$ git checkout -b bug_18897 origin/master
$ git bz apply 18897
$ sudo apt-get remove libcatmandu-store-elasticsearch-perl
...
$ prove t/db_dependent/Koha_Elasticsearch_Indexer.t
-- Note that the message says the correct library is missing.
$ sudo apt-get install libcatmandu-store-elasticsearch-perl
-- Note it runs as expected.
run the koha qa test tools
Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit
088e332760b55c6f7a44097d8ab5d84003d8f0e0)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
use Modern::Perl;
+use Module::Load::Conditional qw[can_load check_install requires];
use Test::More;
use Test::MockModule;
use t::lib::Mocks;
my $schema = Koha::Database->schema();
-eval { require Koha::SearchEngine::Elasticsearch::Indexer; };
-if ( $@ ) {
+if ( ! can_load(
+ modules => { 'Koha::SearchEngine::Elasticsearch::Indexer' => undef, } )
+) {
my $missing_module;
- if ( $@ =~ /Can\'t locate (.*?) / ) {
+ if ( $Module::Load::Conditional::ERROR =~ /Can\'t locate (.*?) / ) {
$missing_module = $1;
}
my $es_dep_msg = "Required module $missing_module is not installed";