From 9d6fa761bc6b69fd9b86b8275489b6afb0584b2a Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Tue, 28 May 2024 13:50:07 +0200
Subject: [PATCH] - fixed override mode - added testcase for override mode

---
 lib/SLUB/LZA/TA/Command/info.pm |  6 +++---
 t/03-info.t                     | 11 ++++++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/SLUB/LZA/TA/Command/info.pm b/lib/SLUB/LZA/TA/Command/info.pm
index 61c3ec6..f2841cb 100644
--- a/lib/SLUB/LZA/TA/Command/info.pm
+++ b/lib/SLUB/LZA/TA/Command/info.pm
@@ -20,19 +20,19 @@ sub description {
 sub opt_spec {
     my @global_opts= SLUB::LZA::TA::common_global_opt_spec();
     my @local_opts = (
-        [ 'target-version|T' => 'get current elasticsearch version', { shortcircuit => 1 } ],
-        [ 'version|V', 'print '.$0.' version information', { shortcircuit => 1 } ],
+        [ 'target-version|T' => 'get current elasticsearch version'],
+        [ 'version|V', 'print '.$0.' version information'],
     );
     return (@global_opts, [], @local_opts);
 }
 sub validate_args {
     my ($self, $opt, $args) = @_;
+    SLUB::LZA::TA::common_global_validate($self, $opt, $args);
     # no args allowed but options!
     $self->usage_error("No args allowed") if @$args;
     return 1;
 }
 
-
 sub execute {
     my ($self, $opt, $args) = @_;
     if ($opt->{target_version}) {
diff --git a/t/03-info.t b/t/03-info.t
index 4c58b07..6aa0261 100644
--- a/t/03-info.t
+++ b/t/03-info.t
@@ -1,6 +1,6 @@
 use v5.36;
 use Test::Cmd;
-use Test::More tests =>12;
+use Test::More tests =>15;
 use Path::Tiny;
 my $perl = $^X;
 my $testapp = Test::Cmd->new(
@@ -28,6 +28,7 @@ user: lza
 _CFG_
 # tests
 
+note "help check";
 foreach my $param ("help info", "info -h", "info --help") {
     $testapp->run(args => $param);
     #say "STDOUT:",$testapp->stdout;
@@ -43,4 +44,12 @@ like($testapp->stdout, qr/^6\.\d\.\d{1,2}$/, 'ta-tool elasticsearch version, std
 like($testapp->stderr, qr/^$/, 'ta-tool elasticsearch version, stderr');
 is($? >> 8, 0, 'ta-tool elasticsearch version, exit status');
 
+$testapp->run(args =>'info --elasticsearch-host localhost --target-version');
+#say "STDOUT:",$testapp->stdout;
+#say "STDERR:",$testapp->stderr;
+like($testapp->stdout, qr/^$/, 'ta-tool elasticsearch version, stdout');
+like($testapp->stderr, qr/^Hint: override local config/, 'ta-tool elasticsearch version, stderr');
+is($? >> 8, 111, 'ta-tool elasticsearch version, exit status');
+
+
 1;
-- 
GitLab