From e548a22a92b3aa345f4a952fddb39cc693c35a70 Mon Sep 17 00:00:00 2001 From: Gavin Carr Date: Tue, 26 Sep 2006 01:10:23 +0000 Subject: Rename NP::Base to NP::Functions; add check_messages() to NP::Functions. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1482 f882894a-f735-0410-b71e-b25c423dba1c --- t/Nagios-Plugin-Base.t | 153 -------------------------------------- t/Nagios-Plugin-Functions-01.t | 153 ++++++++++++++++++++++++++++++++++++++ t/Nagios-Plugin-Functions-02.t | 162 +++++++++++++++++++++++++++++++++++++++++ t/Nagios-Plugin-Performance.t | 6 +- t/Nagios-Plugin-Range.t | 10 ++- t/Nagios-Plugin-Threshold.t | 12 +-- t/Nagios-Plugin.t | 7 +- 7 files changed, 335 insertions(+), 168 deletions(-) delete mode 100644 t/Nagios-Plugin-Base.t create mode 100644 t/Nagios-Plugin-Functions-01.t create mode 100644 t/Nagios-Plugin-Functions-02.t (limited to 't') diff --git a/t/Nagios-Plugin-Base.t b/t/Nagios-Plugin-Base.t deleted file mode 100644 index 68a02fe..0000000 --- a/t/Nagios-Plugin-Base.t +++ /dev/null @@ -1,153 +0,0 @@ - -use strict; -use Test::More tests => 111; - -BEGIN { use_ok("Nagios::Plugin::Base", ":all"); } -Nagios::Plugin::Base::_fake_exit(1); - -my $this_version=$Nagios::Plugin::Base::VERSION; -foreach my $m ("", qw(::Threshold ::Getopt ::Performance ::Range)) { - my $mod = "Nagios::Plugin$m"; - use_ok($mod); - # Lots of hackery below. Easier to say $mod->VERSION, but this is probably a recent perl thing - my $v = "$mod"."::VERSION"; - my $a = eval "\$$v"; - is($a, $this_version, "Version number for $mod the same as Base: $this_version"); -} - -# Hardcoded checks of constants -ok(defined %ERRORS, '%ERRORS defined'); -is(OK, $ERRORS{OK}, "OK => $ERRORS{OK}"); -is(WARNING, $ERRORS{WARNING}, "WARNING => $ERRORS{WARNING}"); -is(CRITICAL, $ERRORS{CRITICAL}, "CRITICAL => $ERRORS{CRITICAL}"); -is(UNKNOWN, $ERRORS{UNKNOWN}, "UNKNOWN => $ERRORS{UNKNOWN}"); -is(DEPENDENT, $ERRORS{DEPENDENT}, "DEPENDENT => $ERRORS{DEPENDENT}"); - -# Test nagios_exit( CONSTANT, $msg ), nagios_exit( $string, $msg ) -my $r; -my @ok = ( - [ OK, "OK", 'test the first', ], - [ WARNING, "WARNING", 'test the second', ], - [ CRITICAL, "CRITICAL", 'test the third', ], - [ UNKNOWN, "UNKNOWN", 'test the fourth', ], - [ DEPENDENT, "DEPENDENT", 'test the fifth', ], -); -for (@ok) { - # CONSTANT - $r = nagios_exit($_->[0], $_->[2]); - is($r->return_code, $_->[0], - sprintf('nagios_exit(%s, $msg) returned %s', $_->[1], $_->[0])); - like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, - sprintf('nagios_exit(%s, $msg) output matched "%s"', - $_->[1], $_->[1] . '.*' . $_->[2])); - - # $string - $r = nagios_exit($_->[1], $_->[2]); - is($r->return_code, $_->[0], - sprintf('nagios_exit("%s", $msg) returned %s', $_->[1], $_->[0])); - like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, - sprintf('nagios_exit("%s", $msg) output matched "%s"', $_->[1], - $_->[1] . '.*' . $_->[2])); - like($r, qr/$_->[1]\b.*\b$_->[2]$/, - sprintf('nagios_exit("%s", $msg) stringified matched "%s"', $_->[1], - $_->[1] . '.*' . $_->[2])); -} - -# nagios_exit code corner cases -my @ugly1 = ( - [ -1, 'testing code -1' ], - [ 7, 'testing code 7' ], - [ undef, 'testing code undef' ], - [ '', qq(testing code '') ], - [ 'string', qq(testing code 'string') ], -); -for (@ugly1) { - $r = nagios_exit($_->[0], $_->[1]); - my $display = defined $_->[0] ? "'$_->[0]'" : 'undef'; - is($r->return_code, UNKNOWN, "nagios_exit($display, \$msg) returned ". UNKNOWN); - like($r->message, qr/UNKNOWN\b.*\b$_->[1]$/, - sprintf('nagios_exit(%s, $msg) output matched "%s"', - $display, 'UNKNOWN.*' . $_->[1])); -} - -# nagios_exit message corner cases -my @ugly2 = ( - [ '' ], - [ undef ], - [ UNKNOWN ], -); -for (@ugly2) { - $r = nagios_exit(CRITICAL, $_->[0]); - my $display1 = defined $_->[0] ? "'$_->[0]'" : "undef"; - my $display2 = defined $_->[0] ? $_->[0] : ''; - like($r->message, qr/CRITICAL\b.*\b$display2$/, - sprintf('nagios_exit(%s, $msg) output matched "%s"', - $display1, "CRITICAL.*$display2")); -} - -# Test nagios_die( $msg ) -my @msg = ( - [ 'die you dog' ], - [ '' ], - [ undef ], -); -for (@msg) { - $r = nagios_die($_->[0]); - my $display1 = defined $_->[0] ? "'$_->[0]'" : "undef"; - my $display2 = defined $_->[0] ? $_->[0] : ''; - is($r->return_code, UNKNOWN, - sprintf('nagios_die(%s) returned UNKNOWN', $display1)); - like($r->message, qr/UNKNOWN\b.*\b$display2$/, - sprintf('nagios_die(%s) output matched "%s"', $display1, - "UNKNOWN.*$display2")); -} - -# Test nagios_die( CONSTANT, $msg ), nagios_die( $msg, CONSTANT ), -# nagios_die( $string, $msg ), and nagios_die( $msg, $string ) -@ok = ( - [ OK, "OK", 'test the first', ], - [ WARNING, "WARNING", 'test the second', ], - [ CRITICAL, "CRITICAL", 'test the third', ], - [ UNKNOWN, "UNKNOWN", 'test the fourth', ], - [ DEPENDENT, "DEPENDENT", 'test the fifth', ], -); -for (@ok) { - # CONSTANT, $msg - $r = nagios_die($_->[0], $_->[2]); - is($r->return_code, $_->[0], - sprintf('nagios_die(%s, $msg) returned %s', $_->[1], $_->[0])); - like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, - sprintf('nagios_die(%s, $msg) output matched "%s"', - $_->[1], $_->[1] . '.*' . $_->[2])); - - # $msg, CONSTANT - $r = nagios_die($_->[2], $_->[0]); - is($r->return_code, $_->[0], - sprintf('nagios_die($msg, %s) returned %s', $_->[1], $_->[0])); - like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, - sprintf('nagios_die($msg, %s) output matched "%s"', - $_->[1], $_->[1] . '.*' . $_->[2])); - - # $string, $msg - $r = nagios_die($_->[1], $_->[2]); - is($r->return_code, $_->[0], - sprintf('nagios_die("%s", $msg) returned %s', $_->[1], $_->[0])); - like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, - sprintf('nagios_die("%s", $msg) output matched "%s"', $_->[1], - $_->[1] . '.*' . $_->[2])); - like($r, qr/$_->[1]\b.*\b$_->[2]$/, - sprintf('nagios_die("%s", $msg) stringified matched "%s"', $_->[1], - $_->[1] . '.*' . $_->[2])); - - # $string, $msg - $r = nagios_die($_->[2], $_->[1]); - is($r->return_code, $_->[0], - sprintf('nagios_die($msg, "%s") returned %s', $_->[1], $_->[0])); - like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, - sprintf('nagios_die($msg, "%s") output matched "%s"', $_->[1], - $_->[1] . '.*' . $_->[2])); - like($r, qr/$_->[1]\b.*\b$_->[2]$/, - sprintf('nagios_die($msg, "%s") stringified matched "%s"', $_->[1], - $_->[1] . '.*' . $_->[2])); -} - diff --git a/t/Nagios-Plugin-Functions-01.t b/t/Nagios-Plugin-Functions-01.t new file mode 100644 index 0000000..7401945 --- /dev/null +++ b/t/Nagios-Plugin-Functions-01.t @@ -0,0 +1,153 @@ + +use strict; +use Test::More tests => 111; + +BEGIN { use_ok("Nagios::Plugin::Functions", ":all"); } +Nagios::Plugin::Functions::_fake_exit(1); + +my $this_version=$Nagios::Plugin::Functions::VERSION; +foreach my $m ("", qw(::Threshold ::Getopt ::Performance ::Range)) { + my $mod = "Nagios::Plugin$m"; + use_ok($mod); + # Lots of hackery below. Easier to say $mod->VERSION, but this is probably a recent perl thing + my $v = "$mod"."::VERSION"; + my $a = eval "\$$v"; + is($a, $this_version, "Version number for $mod the same as Functions: $this_version"); +} + +# Hardcoded checks of constants +ok(defined %ERRORS, '%ERRORS defined'); +is(OK, $ERRORS{OK}, "OK => $ERRORS{OK}"); +is(WARNING, $ERRORS{WARNING}, "WARNING => $ERRORS{WARNING}"); +is(CRITICAL, $ERRORS{CRITICAL}, "CRITICAL => $ERRORS{CRITICAL}"); +is(UNKNOWN, $ERRORS{UNKNOWN}, "UNKNOWN => $ERRORS{UNKNOWN}"); +is(DEPENDENT, $ERRORS{DEPENDENT}, "DEPENDENT => $ERRORS{DEPENDENT}"); + +# Test nagios_exit( CONSTANT, $msg ), nagios_exit( $string, $msg ) +my $r; +my @ok = ( + [ OK, "OK", 'test the first', ], + [ WARNING, "WARNING", 'test the second', ], + [ CRITICAL, "CRITICAL", 'test the third', ], + [ UNKNOWN, "UNKNOWN", 'test the fourth', ], + [ DEPENDENT, "DEPENDENT", 'test the fifth', ], +); +for (@ok) { + # CONSTANT + $r = nagios_exit($_->[0], $_->[2]); + is($r->return_code, $_->[0], + sprintf('nagios_exit(%s, $msg) returned %s', $_->[1], $_->[0])); + like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, + sprintf('nagios_exit(%s, $msg) output matched "%s"', + $_->[1], $_->[1] . '.*' . $_->[2])); + + # $string + $r = nagios_exit($_->[1], $_->[2]); + is($r->return_code, $_->[0], + sprintf('nagios_exit("%s", $msg) returned %s', $_->[1], $_->[0])); + like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, + sprintf('nagios_exit("%s", $msg) output matched "%s"', $_->[1], + $_->[1] . '.*' . $_->[2])); + like($r, qr/$_->[1]\b.*\b$_->[2]$/, + sprintf('nagios_exit("%s", $msg) stringified matched "%s"', $_->[1], + $_->[1] . '.*' . $_->[2])); +} + +# nagios_exit code corner cases +my @ugly1 = ( + [ -1, 'testing code -1' ], + [ 7, 'testing code 7' ], + [ undef, 'testing code undef' ], + [ '', qq(testing code '') ], + [ 'string', qq(testing code 'string') ], +); +for (@ugly1) { + $r = nagios_exit($_->[0], $_->[1]); + my $display = defined $_->[0] ? "'$_->[0]'" : 'undef'; + is($r->return_code, UNKNOWN, "nagios_exit($display, \$msg) returned ". UNKNOWN); + like($r->message, qr/UNKNOWN\b.*\b$_->[1]$/, + sprintf('nagios_exit(%s, $msg) output matched "%s"', + $display, 'UNKNOWN.*' . $_->[1])); +} + +# nagios_exit message corner cases +my @ugly2 = ( + [ '' ], + [ undef ], + [ UNKNOWN ], +); +for (@ugly2) { + $r = nagios_exit(CRITICAL, $_->[0]); + my $display1 = defined $_->[0] ? "'$_->[0]'" : "undef"; + my $display2 = defined $_->[0] ? $_->[0] : ''; + like($r->message, qr/CRITICAL\b.*\b$display2$/, + sprintf('nagios_exit(%s, $msg) output matched "%s"', + $display1, "CRITICAL.*$display2")); +} + +# Test nagios_die( $msg ) +my @msg = ( + [ 'die you dog' ], + [ '' ], + [ undef ], +); +for (@msg) { + $r = nagios_die($_->[0]); + my $display1 = defined $_->[0] ? "'$_->[0]'" : "undef"; + my $display2 = defined $_->[0] ? $_->[0] : ''; + is($r->return_code, UNKNOWN, + sprintf('nagios_die(%s) returned UNKNOWN', $display1)); + like($r->message, qr/UNKNOWN\b.*\b$display2$/, + sprintf('nagios_die(%s) output matched "%s"', $display1, + "UNKNOWN.*$display2")); +} + +# Test nagios_die( CONSTANT, $msg ), nagios_die( $msg, CONSTANT ), +# nagios_die( $string, $msg ), and nagios_die( $msg, $string ) +@ok = ( + [ OK, "OK", 'test the first', ], + [ WARNING, "WARNING", 'test the second', ], + [ CRITICAL, "CRITICAL", 'test the third', ], + [ UNKNOWN, "UNKNOWN", 'test the fourth', ], + [ DEPENDENT, "DEPENDENT", 'test the fifth', ], +); +for (@ok) { + # CONSTANT, $msg + $r = nagios_die($_->[0], $_->[2]); + is($r->return_code, $_->[0], + sprintf('nagios_die(%s, $msg) returned %s', $_->[1], $_->[0])); + like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, + sprintf('nagios_die(%s, $msg) output matched "%s"', + $_->[1], $_->[1] . '.*' . $_->[2])); + + # $msg, CONSTANT + $r = nagios_die($_->[2], $_->[0]); + is($r->return_code, $_->[0], + sprintf('nagios_die($msg, %s) returned %s', $_->[1], $_->[0])); + like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, + sprintf('nagios_die($msg, %s) output matched "%s"', + $_->[1], $_->[1] . '.*' . $_->[2])); + + # $string, $msg + $r = nagios_die($_->[1], $_->[2]); + is($r->return_code, $_->[0], + sprintf('nagios_die("%s", $msg) returned %s', $_->[1], $_->[0])); + like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, + sprintf('nagios_die("%s", $msg) output matched "%s"', $_->[1], + $_->[1] . '.*' . $_->[2])); + like($r, qr/$_->[1]\b.*\b$_->[2]$/, + sprintf('nagios_die("%s", $msg) stringified matched "%s"', $_->[1], + $_->[1] . '.*' . $_->[2])); + + # $string, $msg + $r = nagios_die($_->[2], $_->[1]); + is($r->return_code, $_->[0], + sprintf('nagios_die($msg, "%s") returned %s', $_->[1], $_->[0])); + like($r->message, qr/$_->[1]\b.*\b$_->[2]$/, + sprintf('nagios_die($msg, "%s") output matched "%s"', $_->[1], + $_->[1] . '.*' . $_->[2])); + like($r, qr/$_->[1]\b.*\b$_->[2]$/, + sprintf('nagios_die($msg, "%s") stringified matched "%s"', $_->[1], + $_->[1] . '.*' . $_->[2])); +} + diff --git a/t/Nagios-Plugin-Functions-02.t b/t/Nagios-Plugin-Functions-02.t new file mode 100644 index 0000000..981e2eb --- /dev/null +++ b/t/Nagios-Plugin-Functions-02.t @@ -0,0 +1,162 @@ +# check_messages tests + +use strict; +use Test::More tests => 33; + +BEGIN { use_ok("Nagios::Plugin::Functions", ":all") } + +my ($code, $message); + +# ------------------------------------------------------------------------- +# Check codes +my @codes = ( + [ [ qw(Critical) ], [ qw(Warning) ], CRITICAL ], + [ [], [ qw(Warning) ], WARNING ], + [ [], [], OK ], +); +my $i = 0; +for (@codes) { + $i++; + $code = check_messages( critical => $_->[0], warning => $_->[1] ); + is($code, $_->[2], "Code test $i returned $STATUS_TEXT{$_->[2]}"); +} + +# ------------------------------------------------------------------------- +# Check messages +my %arrays = ( + critical => [ qw(A B C) ], + warning => [ qw(D E F) ], + ok => [ qw(G H I) ], +); +my %messages = map { $_ => join(' ', @{$arrays{$_}}) } keys %arrays; + +# critical, warning +($code, $message) = check_messages( + critical => $arrays{critical}, warning => $arrays{warning}, +); +is($code, CRITICAL, "(critical, warning) code is $STATUS_TEXT{$code}"); +is($message, $messages{critical}, "(critical, warning) message is $message"); + +# critical, warning, ok +($code, $message) = check_messages( + critical => $arrays{critical}, warning => $arrays{warning}, + ok => $arrays{ok}, +); +is($code, CRITICAL, "(critical, warning, ok) code is $STATUS_TEXT{$code}"); +is($message, $messages{critical}, "(critical, warning, ok) message is $message"); + +# critical, warning, $ok +($code, $message) = check_messages( + critical => $arrays{critical}, warning => $arrays{warning}, + ok => 'G H I', +); +is($code, CRITICAL, "(critical, warning, \$ok) code is $STATUS_TEXT{$code}"); +is($message, $messages{critical}, "(critical, warning, \$ok) message is $message"); + +# warning +($code, $message) = check_messages( + critical => [], warning => $arrays{warning}, +); +is($code, WARNING, "(warning) code is $STATUS_TEXT{$code}"); +is($message, $messages{warning}, "(warning) message is $message"); + +# warning, ok +($code, $message) = check_messages( + critical => [], warning => $arrays{warning}, ok => $arrays{ok}, +); +is($code, WARNING, "(warning, ok) code is $STATUS_TEXT{$code}"); +is($message, $messages{warning}, "(warning, ok) message is $message"); + +# ok +($code, $message) = check_messages( + critical => [], warning => [], ok => $arrays{ok}, +); +is($code, OK, "(ok) code is $STATUS_TEXT{$code}"); +is($message, $messages{ok}, "(ok) message is $message"); + +# $ok +($code, $message) = check_messages( + critical => [], warning => [], ok => 'G H I', +); +is($code, OK, "(\$ok) code is $STATUS_TEXT{$code}"); +is($message, $messages{ok}, "(\$ok) message is $message"); + +# ------------------------------------------------------------------------- +# explicit join +my $join = '+'; +($code, $message) = check_messages( + critical => $arrays{critical}, warning => $arrays{warning}, + join => $join, +); +is($message, join($join, @{$arrays{critical}}), "joined '$join' (critical, warning) message is $message"); +$join = ''; +($code, $message) = check_messages( + critical => [], warning => $arrays{warning}, + join => $join, +); +is($message, join($join, @{$arrays{warning}}), "joined '$join' (warning) message is $message"); +$join = undef; +($code, $message) = check_messages( + critical => [], warning => [], ok => $arrays{ok}, + join => $join, +); +is($message, join(' ', @{$arrays{ok}}), "joined undef (ok) message is $message"); + +# ------------------------------------------------------------------------- +# join_all messages +my $join_all = ' :: '; +my $msg_all_cwo = join($join_all, map { join(' ', @{$arrays{$_}}) } + qw(critical warning ok)); +my $msg_all_cw = join($join_all, map { join(' ', @{$arrays{$_}}) } + qw(critical warning)); +my $msg_all_wo = join($join_all, map { join(' ', @{$arrays{$_}}) } + qw(warning ok)); + +# critical, warning, ok +($code, $message) = check_messages( + critical => $arrays{critical}, warning => $arrays{warning}, ok => $arrays{ok}, + join_all => $join_all, +); +is($code, CRITICAL, "(critical, warning, ok) code is $STATUS_TEXT{$code}"); +is($message, $msg_all_cwo, "join_all '$join_all' (critical, warning, ok) message is $message"); + +# critical, warning, $ok +($code, $message) = check_messages( + critical => $arrays{critical}, warning => $arrays{warning}, ok => 'G H I', + join_all => $join_all, +); +is($code, CRITICAL, "(critical, warning, \$ok) code is $STATUS_TEXT{$code}"); +is($message, $msg_all_cwo, "join_all '$join_all' (critical, warning, \$ok) message is $message"); + +# critical, warning +($code, $message) = check_messages( + critical => $arrays{critical}, warning => $arrays{warning}, + join_all => $join_all, +); +is($code, CRITICAL, "(critical, warning) code is $STATUS_TEXT{$code}"); +is($message, $msg_all_cw, "join_all '$join_all' (critical, warning) message is $message"); + +# warning, ok +($code, $message) = check_messages( + critical => [], warning => $arrays{warning}, ok => $arrays{ok}, + join_all => $join_all, +); +is($code, WARNING, "(warning, ok) code is $STATUS_TEXT{$code}"); +is($message, $msg_all_wo, "join_all '$join_all' (critical, warning, ok) message is $message"); + +# warning, $ok +($code, $message) = check_messages( + critical => [], warning => $arrays{warning}, ok => 'G H I', + join_all => $join_all, +); +is($code, WARNING, "(warning, \$ok) code is $STATUS_TEXT{$code}"); +is($message, $msg_all_wo, "join_all '$join_all' (critical, warning, \$ok) message is $message"); + +# warning +($code, $message) = check_messages( + critical => [], warning => $arrays{warning}, + join_all => $join_all, +); +is($code, WARNING, "(warning) code is $STATUS_TEXT{$code}"); +is($message, 'D E F', "join_all '$join_all' (critical, warning) message is $message"); + diff --git a/t/Nagios-Plugin-Performance.t b/t/Nagios-Plugin-Performance.t index 1da3191..e0eb2f6 100644 --- a/t/Nagios-Plugin-Performance.t +++ b/t/Nagios-Plugin-Performance.t @@ -3,10 +3,10 @@ use strict; use Test::More tests => 49; BEGIN { use_ok('Nagios::Plugin::Performance') }; -diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n"; +diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE}; -use Nagios::Plugin::Base; -Nagios::Plugin::Base::_fake_exit(1); +use Nagios::Plugin::Functions; +Nagios::Plugin::Functions::_fake_exit(1); my @p = Nagios::Plugin::Performance->parse_perfstring("/=382MB;15264;15269;; /var=218MB;9443;9448"); cmp_ok( $p[0]->label, 'eq', "/", "label okay"); diff --git a/t/Nagios-Plugin-Range.t b/t/Nagios-Plugin-Range.t index f01518d..df5dbd5 100644 --- a/t/Nagios-Plugin-Range.t +++ b/t/Nagios-Plugin-Range.t @@ -2,13 +2,17 @@ use strict; use Test::More qw(no_plan); #tests => 123; -BEGIN { use_ok('Nagios::Plugin::Range') }; +BEGIN { + use_ok('Nagios::Plugin::Range'); + # Silence warnings unless TEST_VERBOSE is set + $SIG{__WARN__} = sub { warn $_[0] if $ENV{TEST_VERBOSE} }; +}; -diag "\nusing Nagios::Plugin::Range revision ". $Nagios::Plugin::Range::VERSION . "\n"; +diag "\nusing Nagios::Plugin::Range revision ". $Nagios::Plugin::Range::VERSION . "\n" if $ENV{TEST_VERBOSE}; my $r; -diag "'garbage in' checks -- you should see 7 invalid range definition warnings here:"; +diag "'garbage in' checks -- you should see 7 invalid range definition warnings here:" if $ENV{TEST_VERBOSE}; foreach (qw( : diff --git a/t/Nagios-Plugin-Threshold.t b/t/Nagios-Plugin-Threshold.t index 677c054..cdb8d77 100644 --- a/t/Nagios-Plugin-Threshold.t +++ b/t/Nagios-Plugin-Threshold.t @@ -4,7 +4,7 @@ use Test::More tests => 71; #use Test::Exception; # broken for now so we don't need this. BEGIN { use_ok('Nagios::Plugin::Threshold'); - use_ok('Nagios::Plugin::Base', ':all' ); + use_ok('Nagios::Plugin::Functions', ':all' ); # Silence warnings unless TEST_VERBOSE is set $SIG{__WARN__} = sub { warn $_[0] if $ENV{TEST_VERBOSE} }; } @@ -12,7 +12,7 @@ BEGIN { diag "\nusing Nagios::Plugin::Threshold revision ". $Nagios::Plugin::Threshold::VERSION . "\n" if $ENV{TEST_VERBOSE}; -Nagios::Plugin::Base::_fake_exit(1); +Nagios::Plugin::Functions::_fake_exit(1); diag "threshold: critical if > 80" if $ENV{TEST_VERBOSE}; my $t = Nagios::Plugin::Threshold->set_thresholds(critical => "80"); @@ -96,8 +96,8 @@ test_expected_statuses( $t, $expected ); goto SKIP_DEATH; diag "threshold: test pure crap for arguments - default to OK." if $ENV{TEST_VERBOSE}; diag "you should see one invalid range definition warning and an UNKNOWN line here:\n"; -Nagios::Plugin::Base->print_on_die(1); -Nagios::Plugin::Base->exit_on_die(1); +Nagios::Plugin::Functions->print_on_die(1); +Nagios::Plugin::Functions->exit_on_die(1); dies_ok( sub { $t = Nagios::Plugin::Threshold->set_thresholds( @@ -106,8 +106,8 @@ dies_ok( sub { ) }, "bad thresholds cause death" ); -Nagios::Plugin::Base->print_on_die(0); -Nagios::Plugin::Base->exit_on_die(0); +Nagios::Plugin::Functions->print_on_die(0); +Nagios::Plugin::Functions->exit_on_die(0); SKIP_DEATH: diff --git a/t/Nagios-Plugin.t b/t/Nagios-Plugin.t index 213e514..0ae2113 100644 --- a/t/Nagios-Plugin.t +++ b/t/Nagios-Plugin.t @@ -4,10 +4,11 @@ use Test::More tests => 12; BEGIN { use_ok('Nagios::Plugin') }; -use Nagios::Plugin::Base; -Nagios::Plugin::Base::_fake_exit(1); +use Nagios::Plugin::Functions; +Nagios::Plugin::Functions::_fake_exit(1); -diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n"; +diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n" + if $ENV{TEST_VERBOSE}; my $p = Nagios::Plugin->new; isa_ok( $p, "Nagios::Plugin"); -- cgit v1.2.3-74-g34f1