aboutsummaryrefslogtreecommitdiff
path: root/plugins/t
diff options
context:
space:
mode:
authorGravatar Ton Voon <tonvoon@users.sourceforge.net> 2007-05-24 08:53:50 +0000
committerGravatar Ton Voon <tonvoon@users.sourceforge.net> 2007-05-24 08:53:50 +0000
commit3f5fbd9797feffe31cc7046d2abd0ef819a703e8 (patch)
treee38a2f306bcd9ed84d5060261014b7adf6721376 /plugins/t
parenteaf9908edd7bce25412dcdf4d96b23f3a3cafd57 (diff)
downloadmonitoring-plugins-3f5fbd9797feffe31cc7046d2abd0ef819a703e8.tar.gz
Test for new functionality in negate (not automatically run in make test)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1717 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/negate.pl48
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/t/negate.pl b/plugins/t/negate.pl
new file mode 100644
index 00000000..6c56d4f4
--- /dev/null
+++ b/plugins/t/negate.pl
@@ -0,0 +1,48 @@
+#! /usr/bin/perl -w -I ..
+#
+# negate checks
+# Need check_dummy to work for testing
+#
+# $Id$
+#
+
+use strict;
+use Test::More;
+use NPTest;
+
+plan tests => 40;
+
+my $res;
+
+$res = NPTest->testCmd( "./negate" );
+is( $res->return_code, 3, "Not enough parameters");
+like( $res->output, "/Could not parse arguments/", "Could not parse arguments");
+
+$res = NPTest->testCmd( "./negate ./check_dummy 0 'a dummy okay'" );
+is( $res->return_code, 2, "OK changed to CRITICAL" );
+is( $res->output, "OK: a dummy okay" );
+
+$res = NPTest->testCmd( "./negate './check_dummy 0 redsweaterblog'");
+is( $res->return_code, 2, "OK => CRIT with a single quote for command to run" );
+is( $res->output, "OK: redsweaterblog" );
+
+$res = NPTest->testCmd( "./negate ./check_dummy 1 'a warn a day keeps the managers at bay'" );
+is( $res->return_code, 2, "WARN stays same" );
+
+$res = NPTest->testCmd( "./negate ./check_dummy 3 mysterious");
+is( $res->return_code, 3, "UNKNOWN stays same" );
+
+my %state = (
+ ok => 0,
+ warning => 1,
+ critical => 2,
+ unknown => 3,
+ );
+foreach my $current_state (qw(ok warning critical unknown)) {
+ foreach my $new_state (qw(ok warning critical unknown)) {
+ $res = NPTest->testCmd( "./negate --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" );
+ is( $res->return_code, $state{$new_state}, "Got fake $new_state" );
+ is( $res->output, uc($current_state).": Fake $new_state" );
+ }
+}
+