summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2007-05-24 08:53:50 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2007-05-24 08:53:50 (GMT)
commit3f5fbd9797feffe31cc7046d2abd0ef819a703e8 (patch)
treee38a2f306bcd9ed84d5060261014b7adf6721376
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
-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 0000000..6c56d4f
--- /dev/null
+++ b/plugins/t/negate.pl
@@ -0,0 +1,48 @@
1#! /usr/bin/perl -w -I ..
2#
3# negate checks
4# Need check_dummy to work for testing
5#
6# $Id$
7#
8
9use strict;
10use Test::More;
11use NPTest;
12
13plan tests => 40;
14
15my $res;
16
17$res = NPTest->testCmd( "./negate" );
18is( $res->return_code, 3, "Not enough parameters");
19like( $res->output, "/Could not parse arguments/", "Could not parse arguments");
20
21$res = NPTest->testCmd( "./negate ./check_dummy 0 'a dummy okay'" );
22is( $res->return_code, 2, "OK changed to CRITICAL" );
23is( $res->output, "OK: a dummy okay" );
24
25$res = NPTest->testCmd( "./negate './check_dummy 0 redsweaterblog'");
26is( $res->return_code, 2, "OK => CRIT with a single quote for command to run" );
27is( $res->output, "OK: redsweaterblog" );
28
29$res = NPTest->testCmd( "./negate ./check_dummy 1 'a warn a day keeps the managers at bay'" );
30is( $res->return_code, 2, "WARN stays same" );
31
32$res = NPTest->testCmd( "./negate ./check_dummy 3 mysterious");
33is( $res->return_code, 3, "UNKNOWN stays same" );
34
35my %state = (
36 ok => 0,
37 warning => 1,
38 critical => 2,
39 unknown => 3,
40 );
41foreach my $current_state (qw(ok warning critical unknown)) {
42 foreach my $new_state (qw(ok warning critical unknown)) {
43 $res = NPTest->testCmd( "./negate --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" );
44 is( $res->return_code, $state{$new_state}, "Got fake $new_state" );
45 is( $res->output, uc($current_state).": Fake $new_state" );
46 }
47}
48