logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

nagiosplug/plugins/t negate.pl,NONE,1.1: msg#00022

Subject: nagiosplug/plugins/t negate.pl,NONE,1.1
Update of /cvsroot/nagiosplug/nagiosplug/plugins/t
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv9023/t

Added Files:
        negate.pl 
Log Message:
Test for new functionality in negate (not automatically run in make test)


--- NEW FILE: negate.pl ---
#! /usr/bin/perl -w -I ..
#
# negate checks
# Need check_dummy to work for testing
#
# $Id: negate.pl,v 1.1 2007/05/24 08:53:50 tonvoon Exp $
#

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" );
        }
}



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/


<Prev in Thread] Current Thread [Next in Thread>