diff options
author | Gavin Carr <gonzai@users.sourceforge.net> | 2006-09-26 04:11:39 +0000 |
---|---|---|
committer | Gavin Carr <gonzai@users.sourceforge.net> | 2006-09-26 04:11:39 +0000 |
commit | e574c6e1d997130d1afbf752111cdd642f5672bd (patch) | |
tree | 76e2f75af8908e20539439c997191a3a89e63854 /t/Nagios-Plugin-01.t | |
parent | 3a58d586f935a35390196bbbb65b36d5c651fe93 (diff) | |
download | monitoring-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.t | 51 |
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 | |||
2 | use strict; | ||
3 | use Test::More tests => 12; | ||
4 | |||
5 | BEGIN { use_ok('Nagios::Plugin') }; | ||
6 | |||
7 | use Nagios::Plugin::Functions; | ||
8 | Nagios::Plugin::Functions::_fake_exit(1); | ||
9 | |||
10 | diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n" | ||
11 | if $ENV{TEST_VERBOSE}; | ||
12 | |||
13 | my $p = Nagios::Plugin->new; | ||
14 | isa_ok( $p, "Nagios::Plugin"); | ||
15 | |||
16 | $p->shortname("PAGESIZE"); | ||
17 | is($p->shortname, "PAGESIZE", "shortname set correctly"); | ||
18 | |||
19 | $p = Nagios::Plugin->new; | ||
20 | ok(! defined $p->shortname, "shortname should be unset on new"); | ||
21 | |||
22 | $p = Nagios::Plugin->new( shortname => "SIZE" ); | ||
23 | is($p->shortname, "SIZE", "shortname set correctly on new"); | ||
24 | |||
25 | diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; | ||
26 | my $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 | |||
35 | cmp_ok( $p->all_perfoutput, 'eq', "size=1kB;10:25;~:25", "Perfdata correct"); | ||
36 | |||
37 | my $expected = {qw( | ||
38 | -1 WARNING | ||
39 | 1 WARNING | ||
40 | 20 OK | ||
41 | 25 OK | ||
42 | 26 CRITICAL | ||
43 | 30 CRITICAL | ||
44 | )}; | ||
45 | |||
46 | foreach (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 | |||