From 03e96339e979c4df270f6a52c850807cf2a2eb27 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 15 Apr 2012 13:15:29 +0200 Subject: move 50-icli to author tests --- t/50-icli.at | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ t/50-icli.t | 179 ----------------------------------------------------------- 2 files changed, 179 insertions(+), 179 deletions(-) create mode 100644 t/50-icli.at delete mode 100644 t/50-icli.t (limited to 't') diff --git a/t/50-icli.at b/t/50-icli.at new file mode 100644 index 0000000..2e6f0c7 --- /dev/null +++ b/t/50-icli.at @@ -0,0 +1,179 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; + +# We need commas in our qw list, they're not accidental +no warnings 'qw'; + +use Test::Command tests => (36*3 + 4); + +my $icli = 'bin/icli -f t/in/status.dat -c t/in/objects.cache -xn'; + +my $EMPTY = q{}; + +my $cmd = Test::Command->new(cmd => $icli); + +sub run_filter_test { + my ($prefix, $run, $filter) = @_; + + my $file = $filter; + $file =~ tr/,//d; + $file =~ tr/!/./; + + $cmd = Test::Command->new(cmd => "$icli $run -z $filter"); + $cmd->exit_is_num(0); + $cmd->stdout_is_file("t/out/${prefix}_${file}"); + $cmd->stderr_is_eq($EMPTY); +} + +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/standard'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -V"); +$cmd->exit_is_num(0); +$cmd->stdout_like(qr{ ^ icli \s version \s \S+ $ }x); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -lh -g local"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/hosts_group_local'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -lh -z!o"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/hosts_short'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -ls -h steel-vpn,steel.derf0.net"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/host_steel_steel'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -lh"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/list_hosts'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -lh -C"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/list_hosts_nc'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -ls"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/list_services'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -ls -C"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/list_services_nc'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -ls -g local"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/services_group_local'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -lh -g derf-remote,http-servers"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/hosts_group_reduce'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -ls -z!o"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/services_short'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -ls -h steel.derf0.net"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/list_services_single'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -lh -v"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/list_hosts_v'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -ls -v"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/list_services_v'); +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -lq"); +$cmd->exit_is_num(0); +# no stdout test, fails with timezones != GMT+1 +$cmd->stderr_is_eq($EMPTY); + +$cmd = Test::Command->new(cmd => "$icli -lq -h aneurysm"); +$cmd->exit_is_num(0); +# no stdout test, fails with timezones != GMT+1 +$cmd->stderr_is_eq($EMPTY); + + +$cmd = Test::Command->new(cmd => "$icli -g invalid"); +$cmd->exit_isnt_num(0); +$cmd->stdout_is_eq($EMPTY); +$cmd->stderr_is_eq("Unknown hostgroup: invalid\n"); + +$cmd = Test::Command->new(cmd => "$icli -h invalid"); +$cmd->exit_isnt_num(0); +$cmd->stdout_is_eq($EMPTY); +$cmd->stderr_is_eq("Unknown host: invalid\n"); + +$cmd = Test::Command->new(cmd => "$icli -lh -h invalid"); +$cmd->exit_isnt_num(0); +$cmd->stdout_is_eq($EMPTY); +$cmd->stderr_is_eq("Unknown host: invalid\n"); + +$cmd = Test::Command->new(cmd => "$icli -l INVALID"); +$cmd->exit_isnt_num(0); +$cmd->stdout_is_eq($EMPTY); +$cmd->stderr_is_eq("See perldoc -F bin/icli\n"); + +for my $filter (qw( + A + !A,!o + c + D + !o + !o,!A,!D + S + u + w + )) +{ + run_filter_test('filter', q{}, $filter); +} + +for my $filter (qw( + d + !o + S + S,!x,!A + x + )) +{ + run_filter_test('h_filter', '-lh', $filter); +} + + +$icli = "bin/icli -f t/in/status.dat.weird.1 -c t/in/objects.cache"; + +$cmd = Test::Command->new(cmd => $icli); +$cmd->exit_is_num(0); +$cmd->stdout_is_eq($EMPTY); +$cmd->stderr_is_eq("Unknown field in t/in/status.dat.weird.1: bork\n"); + +$icli = "bin/icli -f t/in/status.dat.weird.2 -c t/in/objects.cache"; + +$cmd = Test::Command->new(cmd => "$icli -lh -h alpha"); +$cmd->exit_isnt_num(0); +$cmd->stdout_is_eq($EMPTY); +$cmd->stderr_like(qr{^Unknown host state: 23}s); + +$cmd = Test::Command->new(cmd => "$icli -ls -h aneurysm"); +$cmd->exit_isnt_num(0); +$cmd->stdout_is_eq('Disk: / '); +$cmd->stderr_like(qr{^Unknown service state: 23}s); diff --git a/t/50-icli.t b/t/50-icli.t deleted file mode 100644 index 2e6f0c7..0000000 --- a/t/50-icli.t +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use 5.010; - -# We need commas in our qw list, they're not accidental -no warnings 'qw'; - -use Test::Command tests => (36*3 + 4); - -my $icli = 'bin/icli -f t/in/status.dat -c t/in/objects.cache -xn'; - -my $EMPTY = q{}; - -my $cmd = Test::Command->new(cmd => $icli); - -sub run_filter_test { - my ($prefix, $run, $filter) = @_; - - my $file = $filter; - $file =~ tr/,//d; - $file =~ tr/!/./; - - $cmd = Test::Command->new(cmd => "$icli $run -z $filter"); - $cmd->exit_is_num(0); - $cmd->stdout_is_file("t/out/${prefix}_${file}"); - $cmd->stderr_is_eq($EMPTY); -} - -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/standard'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -V"); -$cmd->exit_is_num(0); -$cmd->stdout_like(qr{ ^ icli \s version \s \S+ $ }x); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -lh -g local"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/hosts_group_local'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -lh -z!o"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/hosts_short'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -ls -h steel-vpn,steel.derf0.net"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/host_steel_steel'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -lh"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/list_hosts'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -lh -C"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/list_hosts_nc'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -ls"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/list_services'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -ls -C"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/list_services_nc'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -ls -g local"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/services_group_local'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -lh -g derf-remote,http-servers"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/hosts_group_reduce'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -ls -z!o"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/services_short'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -ls -h steel.derf0.net"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/list_services_single'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -lh -v"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/list_hosts_v'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -ls -v"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('t/out/list_services_v'); -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -lq"); -$cmd->exit_is_num(0); -# no stdout test, fails with timezones != GMT+1 -$cmd->stderr_is_eq($EMPTY); - -$cmd = Test::Command->new(cmd => "$icli -lq -h aneurysm"); -$cmd->exit_is_num(0); -# no stdout test, fails with timezones != GMT+1 -$cmd->stderr_is_eq($EMPTY); - - -$cmd = Test::Command->new(cmd => "$icli -g invalid"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq($EMPTY); -$cmd->stderr_is_eq("Unknown hostgroup: invalid\n"); - -$cmd = Test::Command->new(cmd => "$icli -h invalid"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq($EMPTY); -$cmd->stderr_is_eq("Unknown host: invalid\n"); - -$cmd = Test::Command->new(cmd => "$icli -lh -h invalid"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq($EMPTY); -$cmd->stderr_is_eq("Unknown host: invalid\n"); - -$cmd = Test::Command->new(cmd => "$icli -l INVALID"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq($EMPTY); -$cmd->stderr_is_eq("See perldoc -F bin/icli\n"); - -for my $filter (qw( - A - !A,!o - c - D - !o - !o,!A,!D - S - u - w - )) -{ - run_filter_test('filter', q{}, $filter); -} - -for my $filter (qw( - d - !o - S - S,!x,!A - x - )) -{ - run_filter_test('h_filter', '-lh', $filter); -} - - -$icli = "bin/icli -f t/in/status.dat.weird.1 -c t/in/objects.cache"; - -$cmd = Test::Command->new(cmd => $icli); -$cmd->exit_is_num(0); -$cmd->stdout_is_eq($EMPTY); -$cmd->stderr_is_eq("Unknown field in t/in/status.dat.weird.1: bork\n"); - -$icli = "bin/icli -f t/in/status.dat.weird.2 -c t/in/objects.cache"; - -$cmd = Test::Command->new(cmd => "$icli -lh -h alpha"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq($EMPTY); -$cmd->stderr_like(qr{^Unknown host state: 23}s); - -$cmd = Test::Command->new(cmd => "$icli -ls -h aneurysm"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq('Disk: / '); -$cmd->stderr_like(qr{^Unknown service state: 23}s); -- cgit v1.2.3