From 2c6651034f76e2bccb549a867485f8fabbf07cb1 Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Thu, 8 Jun 2006 12:27:44 +0000 Subject: Initial revision git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1419 f882894a-f735-0410-b71e-b25c423dba1c --- t/Nagios-Plugin-Threshold.t | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 t/Nagios-Plugin-Threshold.t (limited to 't/Nagios-Plugin-Threshold.t') 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 @@ + +use strict; +use Test::More tests => 18; +BEGIN { use_ok('Nagios::Plugin::Threshold'); use_ok('Nagios::Plugin::Base') }; + +Nagios::Plugin::Base->exit_on_die(0); +Nagios::Plugin::Base->print_on_die(0); + +my $t = Nagios::Plugin::Threshold->set_thresholds(critical => "80"); +ok( defined $t, "Threshold ('', '80') set"); +ok( ! defined $t->warning, "Warning not set"); +cmp_ok( $t->critical->end, '==', 80, "Critical set correctly"); + +$t = Nagios::Plugin::Threshold->set_thresholds(warning => "5:33", critical => ""); +ok( defined $t, "Threshold ('5:33', '') set"); +cmp_ok( $t->warning->start, '==', 5, "Warning start set"); +cmp_ok( $t->warning->end, '==', 33, "Warning end set"); +ok( ! defined $t->critical, "Critical not set"); + +$t = Nagios::Plugin::Threshold->set_thresholds(warning => "30", critical => "60"); +ok( defined $t, "Threshold ('30', '60') set"); +cmp_ok( $t->warning->end, '==', 30, "Warning end set"); +cmp_ok( $t->critical->end, '==',60, "Critical end set"); +cmp_ok( $t->get_status(15.3), '==', $ERRORS{OK}, "15.3 - ok"); +cmp_ok( $t->get_status(30.0001), '==', $ERRORS{WARNING}, "30.0001 - warning"); +cmp_ok( $t->get_status(69), '==', $ERRORS{CRITICAL}, "69 - critical"); + +$t = Nagios::Plugin::Threshold->set_thresholds(warning => "total", critical => "rubbish"); +ok( defined $t, "Threshold object created although ..."); +ok( ! defined $t->warning, "Warning not set"); +ok( ! defined $t->critical, "Critical not set"); + -- cgit v1.2.3-74-g34f1