diff options
Diffstat (limited to 't/Nagios-Plugin-Threshold.t')
-rw-r--r-- | t/Nagios-Plugin-Threshold.t | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/t/Nagios-Plugin-Threshold.t b/t/Nagios-Plugin-Threshold.t new file mode 100644 index 0000000..764f7b0 --- /dev/null +++ b/t/Nagios-Plugin-Threshold.t | |||
@@ -0,0 +1,32 @@ | |||
1 | |||
2 | use strict; | ||
3 | use Test::More tests => 18; | ||
4 | BEGIN { use_ok('Nagios::Plugin::Threshold'); use_ok('Nagios::Plugin::Base') }; | ||
5 | |||
6 | Nagios::Plugin::Base->exit_on_die(0); | ||
7 | Nagios::Plugin::Base->print_on_die(0); | ||
8 | |||
9 | my $t = Nagios::Plugin::Threshold->set_thresholds(critical => "80"); | ||
10 | ok( defined $t, "Threshold ('', '80') set"); | ||
11 | ok( ! defined $t->warning, "Warning not set"); | ||
12 | cmp_ok( $t->critical->end, '==', 80, "Critical set correctly"); | ||
13 | |||
14 | $t = Nagios::Plugin::Threshold->set_thresholds(warning => "5:33", critical => ""); | ||
15 | ok( defined $t, "Threshold ('5:33', '') set"); | ||
16 | cmp_ok( $t->warning->start, '==', 5, "Warning start set"); | ||
17 | cmp_ok( $t->warning->end, '==', 33, "Warning end set"); | ||
18 | ok( ! defined $t->critical, "Critical not set"); | ||
19 | |||
20 | $t = Nagios::Plugin::Threshold->set_thresholds(warning => "30", critical => "60"); | ||
21 | ok( defined $t, "Threshold ('30', '60') set"); | ||
22 | cmp_ok( $t->warning->end, '==', 30, "Warning end set"); | ||
23 | cmp_ok( $t->critical->end, '==',60, "Critical end set"); | ||
24 | cmp_ok( $t->get_status(15.3), '==', $ERRORS{OK}, "15.3 - ok"); | ||
25 | cmp_ok( $t->get_status(30.0001), '==', $ERRORS{WARNING}, "30.0001 - warning"); | ||
26 | cmp_ok( $t->get_status(69), '==', $ERRORS{CRITICAL}, "69 - critical"); | ||
27 | |||
28 | $t = Nagios::Plugin::Threshold->set_thresholds(warning => "total", critical => "rubbish"); | ||
29 | ok( defined $t, "Threshold object created although ..."); | ||
30 | ok( ! defined $t->warning, "Warning not set"); | ||
31 | ok( ! defined $t->critical, "Critical not set"); | ||
32 | |||