From ced0e983417e7c27ea657a333a8c40b63f35cd4b Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Tue, 28 May 2024 13:49:17 +0200
Subject: [PATCH] - fixed interactive checking

---
 lib/SLUB/LZA/TA/Command/init.pm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/SLUB/LZA/TA/Command/init.pm b/lib/SLUB/LZA/TA/Command/init.pm
index 990df25..b16ef4d 100644
--- a/lib/SLUB/LZA/TA/Command/init.pm
+++ b/lib/SLUB/LZA/TA/Command/init.pm
@@ -44,7 +44,15 @@ sub execute {
     #$config{logdir} = $opt->{logdir};
     $config{http_only} = $opt->{http_only};
     my $in_test = $ENV{TEST_ACTIVE};
-    local *IO::Prompt::Tiny::_is_interactive = sub {$in_test}; # fake it for testing
+    # next lines to fake interactive for testing
+    local *IO::Prompt::Tiny::_is_interactive = *IO::Prompt::Tiny::_is_interactive;
+    if ($in_test) {
+        *IO::Prompt::Tiny::_is_interactive = sub {$in_test};
+    }
+    if (defined $opt->{debug}) {
+        say STDERR "Is test active? ", $ENV{TEST_ACTIVE} ? "true" : "false";
+        say STDERR "Is interactive? ", IO::Prompt::Tiny::_is_interactive() ? "true" : "false";
+    }
     say STDERR "HINT: The password  stored in config file!";
     my $user = prompt('User:');
 RETRY:
-- 
GitLab