Skip to content
Snippets Groups Projects
Commit 9d6fa761 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- fixed override mode

- added testcase for override mode
parent 5c815d06
Branches
Tags
No related merge requests found
...@@ -20,19 +20,19 @@ sub description { ...@@ -20,19 +20,19 @@ sub description {
sub opt_spec { sub opt_spec {
my @global_opts= SLUB::LZA::TA::common_global_opt_spec(); my @global_opts= SLUB::LZA::TA::common_global_opt_spec();
my @local_opts = ( my @local_opts = (
[ 'target-version|T' => 'get current elasticsearch version', { shortcircuit => 1 } ], [ 'target-version|T' => 'get current elasticsearch version'],
[ 'version|V', 'print '.$0.' version information', { shortcircuit => 1 } ], [ 'version|V', 'print '.$0.' version information'],
); );
return (@global_opts, [], @local_opts); return (@global_opts, [], @local_opts);
} }
sub validate_args { sub validate_args {
my ($self, $opt, $args) = @_; my ($self, $opt, $args) = @_;
SLUB::LZA::TA::common_global_validate($self, $opt, $args);
# no args allowed but options! # no args allowed but options!
$self->usage_error("No args allowed") if @$args; $self->usage_error("No args allowed") if @$args;
return 1; return 1;
} }
sub execute { sub execute {
my ($self, $opt, $args) = @_; my ($self, $opt, $args) = @_;
if ($opt->{target_version}) { if ($opt->{target_version}) {
......
use v5.36; use v5.36;
use Test::Cmd; use Test::Cmd;
use Test::More tests =>12; use Test::More tests =>15;
use Path::Tiny; use Path::Tiny;
my $perl = $^X; my $perl = $^X;
my $testapp = Test::Cmd->new( my $testapp = Test::Cmd->new(
...@@ -28,6 +28,7 @@ user: lza ...@@ -28,6 +28,7 @@ user: lza
_CFG_ _CFG_
# tests # tests
note "help check";
foreach my $param ("help info", "info -h", "info --help") { foreach my $param ("help info", "info -h", "info --help") {
$testapp->run(args => $param); $testapp->run(args => $param);
#say "STDOUT:",$testapp->stdout; #say "STDOUT:",$testapp->stdout;
...@@ -43,4 +44,12 @@ like($testapp->stdout, qr/^6\.\d\.\d{1,2}$/, 'ta-tool elasticsearch version, std ...@@ -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'); like($testapp->stderr, qr/^$/, 'ta-tool elasticsearch version, stderr');
is($? >> 8, 0, 'ta-tool elasticsearch version, exit status'); 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; 1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment