summaryrefslogtreecommitdiffstats
path: root/t/Nagios-Plugin-01.t
diff options
context:
space:
mode:
authorGavin Carr <gonzai@users.sourceforge.net>2006-09-26 04:11:39 +0000
committerGavin Carr <gonzai@users.sourceforge.net>2006-09-26 04:11:39 +0000
commite574c6e1d997130d1afbf752111cdd642f5672bd (patch)
tree76e2f75af8908e20539439c997191a3a89e63854 /t/Nagios-Plugin-01.t
parent3a58d586f935a35390196bbbb65b36d5c651fe93 (diff)
downloadmonitoring-plugin-perl-e574c6e1d997130d1afbf752111cdd642f5672bd.tar.gz
Add additional Nagios::Plugin tests.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1484 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 't/Nagios-Plugin-01.t')
-rw-r--r--t/Nagios-Plugin-01.t51
1 files changed, 51 insertions, 0 deletions
diff --git a/t/Nagios-Plugin-01.t b/t/Nagios-Plugin-01.t
new file mode 100644
index 0000000..0ae2113
--- /dev/null
+++ b/t/Nagios-Plugin-01.t
@@ -0,0 +1,51 @@
1
2use strict;
3use Test::More tests => 12;
4
5BEGIN { use_ok('Nagios::Plugin') };
6
7use Nagios::Plugin::Functions;
8Nagios::Plugin::Functions::_fake_exit(1);
9
10diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n"
11 if $ENV{TEST_VERBOSE};
12
13my $p = Nagios::Plugin->new;
14isa_ok( $p, "Nagios::Plugin");
15
16$p->shortname("PAGESIZE");
17is($p->shortname, "PAGESIZE", "shortname set correctly");
18
19$p = Nagios::Plugin->new;
20ok(! defined $p->shortname, "shortname should be unset on new");
21
22$p = Nagios::Plugin->new( shortname => "SIZE" );
23is($p->shortname, "SIZE", "shortname set correctly on new");
24
25diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE};
26my $t = $p->set_thresholds( warning => "10:25", critical => "~:25" );
27
28$p->add_perfdata(
29 label => "size",
30 value => 1,
31 uom => "kB",
32 threshold => $t,
33 );
34
35cmp_ok( $p->all_perfoutput, 'eq', "size=1kB;10:25;~:25", "Perfdata correct");
36
37my $expected = {qw(
38 -1 WARNING
39 1 WARNING
40 20 OK
41 25 OK
42 26 CRITICAL
43 30 CRITICAL
44 )};
45
46foreach (sort {$a<=>$b} keys %$expected) {
47 like $p->die( return_code => $t->get_status($_), message => "page size at http://... was ${_}kB" ),
48 qr/$expected->{$_}/,
49 "Output okay. $_ = $expected->{$_}" ;
50}
51