From 5364075dd0ec2b702d606a814bda43a5e9eec33b Mon Sep 17 00:00:00 2001
From: Lee Jamison <ldjamison@marywood.edu>
Date: Fri, 25 Aug 2017 07:18:15 -0400
Subject: [PATCH] Bug 18897: Koha_Elasticsearch_Indexer.t doesn't skip when ES
 module(s) not installed

If Catmandu::Importer::MARC is not installed,
Koha_Elasticsearch_Indexer.t fails instead of skipping.
It should skip as ES is not currently mandatory.

Test Plan:
1. Run "prove t/db_dependent/Koha_Elasticsearch_Indexer.t"
   as koha-shell
2. Note failure on test 1/5 indicating module not installed.
3. Apply patch.
4. Re-run "prove t/db_dependent/Koha_Elasticsearch_Indexer.t"
5. Note test now skips.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
---
 t/db_dependent/Koha_Elasticsearch_Indexer.t | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/t/db_dependent/Koha_Elasticsearch_Indexer.t b/t/db_dependent/Koha_Elasticsearch_Indexer.t
index 9a525bf..1cb3a7d 100644
--- a/t/db_dependent/Koha_Elasticsearch_Indexer.t
+++ b/t/db_dependent/Koha_Elasticsearch_Indexer.t
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 6;
+use Test::More;
 use Test::MockModule;
 use t::lib::Mocks;
 
@@ -27,6 +27,15 @@ use Koha::Database;
 
 my $schema = Koha::Database->schema();
 
+eval { require Koha::SearchEngine::Elasticsearch::Indexer; };
+if ( $@ ) {
+    my $es_dep_msg = "Required module Catmandu::Importer::MARC is not installed";
+    plan( skip_all => $es_dep_msg );
+}
+else {
+    plan tests => 6;
+}
+
 use_ok('Koha::SearchEngine::Elasticsearch::Indexer');
 
 my $indexer;
-- 
2.7.4