From fbf2154c5a68915dc6197e7a2ff56e56ef924220 Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Thu, 25 May 2006 15:34:54 +0000 Subject: Option to invert results from a regexp pattern match git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1404 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/t/check_http.t | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'plugins/t') diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 3154151f..4e3c06cb 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t @@ -9,7 +9,7 @@ use strict; use Test::More; use NPTest; -plan tests => 14; +plan tests => 21; my $successOutput = '/OK.*HTTP.*second/'; @@ -79,4 +79,19 @@ $res = NPTest->testCmd( ); cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); - +$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nagios'" ); +cmp_ok( $res->return_code, "==", 0, "Got a reference to 'nagios'"); + +$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nAGiOs'" ); +cmp_ok( $res->return_code, "==", 2, "Not got 'nAGiOs'"); +like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'"); + +$res = NPTest->testCmd( "./check_http -H altinity.com -R 'nAGiOs'" ); +cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'nAGiOs'"); + +$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nagios' --invert-regex" ); +cmp_ok( $res->return_code, "==", 2, "Invert results work when found"); +like ( $res->output, "/pattern found/", "Error message says 'pattern found'"); + +$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nAGiOs' --invert-regex" ); +cmp_ok( $res->return_code, "==", 0, "And also when not found"); -- cgit v1.2.3-74-g34f1