summaryrefslogtreecommitdiffstats
path: root/t/Nagios-Plugin-Threshold.t
diff options
context:
space:
mode:
Diffstat (limited to 't/Nagios-Plugin-Threshold.t')
-rw-r--r--t/Nagios-Plugin-Threshold.t32
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
2use strict;
3use Test::More tests => 18;
4BEGIN { use_ok('Nagios::Plugin::Threshold'); use_ok('Nagios::Plugin::Base') };
5
6Nagios::Plugin::Base->exit_on_die(0);
7Nagios::Plugin::Base->print_on_die(0);
8
9my $t = Nagios::Plugin::Threshold->set_thresholds(critical => "80");
10ok( defined $t, "Threshold ('', '80') set");
11ok( ! defined $t->warning, "Warning not set");
12cmp_ok( $t->critical->end, '==', 80, "Critical set correctly");
13
14$t = Nagios::Plugin::Threshold->set_thresholds(warning => "5:33", critical => "");
15ok( defined $t, "Threshold ('5:33', '') set");
16cmp_ok( $t->warning->start, '==', 5, "Warning start set");
17cmp_ok( $t->warning->end, '==', 33, "Warning end set");
18ok( ! defined $t->critical, "Critical not set");
19
20$t = Nagios::Plugin::Threshold->set_thresholds(warning => "30", critical => "60");
21ok( defined $t, "Threshold ('30', '60') set");
22cmp_ok( $t->warning->end, '==', 30, "Warning end set");
23cmp_ok( $t->critical->end, '==',60, "Critical end set");
24cmp_ok( $t->get_status(15.3), '==', $ERRORS{OK}, "15.3 - ok");
25cmp_ok( $t->get_status(30.0001), '==', $ERRORS{WARNING}, "30.0001 - warning");
26cmp_ok( $t->get_status(69), '==', $ERRORS{CRITICAL}, "69 - critical");
27
28$t = Nagios::Plugin::Threshold->set_thresholds(warning => "total", critical => "rubbish");
29ok( defined $t, "Threshold object created although ...");
30ok( ! defined $t->warning, "Warning not set");
31ok( ! defined $t->critical, "Critical not set");
32