diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2005-11-09 16:40:12 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2005-11-09 16:40:12 +0000 |
commit | 6224ec31587dc70b21b487a57d59cb863c2cd3a8 (patch) | |
tree | 29329797f7e4b4211f119d267ff446bf93a95b57 /plugins/t/check_imap.t | |
parent | 38873559580dab20ad4a450136b980849874ed57 (diff) | |
download | monitoring-plugins-6224ec31587dc70b21b487a57d59cb863c2cd3a8.tar.gz |
Added new NPTest->testCmd which returns objects back for testing
at the test script level. Updated check_swap and check_imap to this
new format
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1279 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t/check_imap.t')
-rw-r--r-- | plugins/t/check_imap.t | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/plugins/t/check_imap.t b/plugins/t/check_imap.t index 32b4136a..fa957d1b 100644 --- a/plugins/t/check_imap.t +++ b/plugins/t/check_imap.t | |||
@@ -6,12 +6,9 @@ | |||
6 | # | 6 | # |
7 | 7 | ||
8 | use strict; | 8 | use strict; |
9 | use Test; | 9 | use Test::More tests => 7; |
10 | use NPTest; | 10 | use NPTest; |
11 | 11 | ||
12 | use vars qw($tests); | ||
13 | BEGIN {$tests = 7; plan tests => $tests} | ||
14 | |||
15 | my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", | 12 | my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", |
16 | "A host providing an STMP Service (a mail server)"); | 13 | "A host providing an STMP Service (a mail server)"); |
17 | 14 | ||
@@ -24,18 +21,26 @@ my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRES | |||
24 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | 21 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", |
25 | "An invalid (not known to DNS) hostname" ); | 22 | "An invalid (not known to DNS) hostname" ); |
26 | 23 | ||
27 | my %exceptions = ( 2 => "No IMAP Server present?" ); | ||
28 | |||
29 | my $t; | 24 | my $t; |
30 | 25 | ||
31 | $t += checkCmd( "./check_imap $host_tcp_imap", 0, undef, %exceptions ); | 26 | $t = NPTest->testCmd( "./check_imap $host_tcp_imap" ); |
32 | $t += checkCmd( "./check_imap -H $host_tcp_imap -p 143 -w 9 -c 9 -t 10 -e '* OK'", 0, undef, %exceptions ); | 27 | cmp_ok( $t->return_code, '==', 0, "Contacted imap" ); |
33 | $t += checkCmd( "./check_imap $host_tcp_imap -p 143 -wt 9 -ct 9 -to 10 -e '* OK'", 0, undef, %exceptions ); | 28 | |
34 | $t += checkCmd( "./check_imap $host_nonresponsive", 2 ); | 29 | $t = NPTest->testCmd( "./check_imap -H $host_tcp_imap -p 143 -w 9 -c 9 -to 10 -e '* OK'" ); |
35 | $t += checkCmd( "./check_imap $hostname_invalid", 2 ); | 30 | cmp_ok( $t->return_code, '==', 0, "Got right response" ); |
36 | $t += checkCmd( "./check_imap -H $host_tcp_imap -e unlikely_string", 1); | 31 | |
37 | $t += checkCmd( "./check_imap -H $host_tcp_imap -e unlikely_string -M crit", 2); | 32 | $t = NPTest->testCmd( "./check_imap $host_tcp_imap -p 143 -wt 9 -ct 9 -to 10 -e '* OK'" ); |
33 | cmp_ok( $t->return_code, '==', 0, "Check old parameter options" ); | ||
34 | |||
35 | $t = NPTest->testCmd( "./check_imap $host_nonresponsive" ); | ||
36 | cmp_ok( $t->return_code, '==', 2, "Get error with non reponsive host" ); | ||
37 | |||
38 | $t = NPTest->testCmd( "./check_imap $hostname_invalid" ); | ||
39 | cmp_ok( $t->return_code, '==', 2, "Invalid hostname" ); | ||
40 | |||
41 | $t = NPTest->testCmd( "./check_imap -H $host_tcp_imap -e unlikely_string"); | ||
42 | cmp_ok( $t->return_code, '==', 1, "Got warning with bad response" ); | ||
38 | 43 | ||
44 | $t = NPTest->testCmd( "./check_imap -H $host_tcp_imap -e unlikely_string -M crit"); | ||
45 | cmp_ok( $t->return_code, '==', 2, "Got critical error with bad response" ); | ||
39 | 46 | ||
40 | exit(0) if defined($Test::Harness::VERSION); | ||
41 | exit($tests - $t); | ||