From f0b3c4335518eef4cd3ed6165bdd547758b4a532 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Wed, 20 Dec 2017 19:10:44 -0300
Subject: [PATCH] Bug 19712: Fix test mode for delete_records_via_leader.pl

Test plan:
perl misc/cronjobs/delete_records_via_leader.pl
=> Should display a warning
perl misc/cronjobs/delete_records_via_leader.pl --test
=> Should not display a warning and script should not apply changes
perl misc/cronjobs/delete_records_via_leader.pl --confirm
=> Should not display a warning and script should apply changes

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
---
 misc/cronjobs/delete_records_via_leader.pl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/misc/cronjobs/delete_records_via_leader.pl b/misc/cronjobs/delete_records_via_leader.pl
index b4d8781..291ab6b 100755
--- a/misc/cronjobs/delete_records_via_leader.pl
+++ b/misc/cronjobs/delete_records_via_leader.pl
@@ -53,7 +53,14 @@ GetOptions(
     'h|help'            => \$help,
 );
 
-if ( $help || !$confirm ) {
+pod2usage(q|--test and --confirm cannot be specified together|) if $test and $confirm;
+
+unless ( $confirm or $test ) {
+    warn "Running in test mode as --confirm is not passed\n";
+    $test = 1;
+}
+
+if ( $help ) {
     say qq{
 delete_records_via_leader.pl - Attempt to delete any MARC records where the leader character 5 equals 'd'
 usage: delete_records_via_leader.pl --confirm --verbose [--test]
-- 
2.1.4