From 96933fd2e1f53aff9c9ef26639fafe9a84ec754e Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Fri, 4 Aug 2006 20:22:31 +0000 Subject: Lots of extra tests and subsequent fixes (Nathan Vonnahme) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1466 f882894a-f735-0410-b71e-b25c423dba1c --- t/Nagios-Plugin.t | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 't/Nagios-Plugin.t') diff --git a/t/Nagios-Plugin.t b/t/Nagios-Plugin.t index 38e792d..ed25aca 100644 --- a/t/Nagios-Plugin.t +++ b/t/Nagios-Plugin.t @@ -1,18 +1,22 @@ use strict; -use Test::More tests => 5; +use Test::More tests => 9; + BEGIN { use_ok('Nagios::Plugin') }; use Nagios::Plugin::Base; Nagios::Plugin::Base->exit_on_die(0); Nagios::Plugin::Base->print_on_die(0); +diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n"; + my $p = Nagios::Plugin->new; isa_ok( $p, "Nagios::Plugin"); $p->shortname("PAGESIZE"); -my $t = $p->set_thresholds( warning => "10:25", critical => "25:" ); +diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; +my $t = $p->set_thresholds( warning => "10:25", critical => "~:25" ); $p->add_perfdata( label => "size", @@ -21,12 +25,20 @@ $p->add_perfdata( threshold => $t, ); -cmp_ok( $p->all_perfoutput, 'eq', "size=1kB;10:25;25:", "Perfdata correct"); - -my $o = $p->die( return_code => $t->get_status(1), message => "page size at http://... was 1kB" ); -cmp_ok( $o, "eq", 'PAGESIZE CRITICAL page size at http://... was 1kB | size=1kB;10:25;25:', "Output okay"); - -cmp_ok( $p->die( return_code => $t->get_status(30), message => "page size at http://... was 30kB" ), - "eq", 'PAGESIZE WARNING page size at http://... was 30kB | size=1kB;10:25;25:', "Output okay"); - +cmp_ok( $p->all_perfoutput, 'eq', "size=1kB;10:25;~:25", "Perfdata correct"); + +my $expected = {qw( + -1 WARNING + 1 WARNING + 20 OK + 25 OK + 26 CRITICAL + 30 CRITICAL + )}; + +foreach (sort {$a<=>$b} keys %$expected) { + like $p->die( return_code => $t->get_status($_), message => "page size at http://... was ${_}kB" ), + qr/$expected->{$_}/, + "Output okay. $_ = $expected->{$_}" ; +} -- cgit v1.2.3-74-g34f1