diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2005-11-09 17:27:36 (GMT) |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2005-11-09 17:27:36 (GMT) |
commit | 15330698d4294d428e10a38aa8e82207e57272d1 (patch) | |
tree | 8dd6c15c6a98e99bde350d46ba0b0170dfbadcfe /plugins/t | |
parent | 6224ec31587dc70b21b487a57d59cb863c2cd3a8 (diff) | |
download | monitoring-plugins-15330698d4294d428e10a38aa8e82207e57272d1.tar.gz |
Using Test::More
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1280 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t')
-rw-r--r-- | plugins/t/check_mysql.t | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index ad42359..b29c5c6 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t | |||
@@ -6,28 +6,27 @@ | |||
6 | # | 6 | # |
7 | 7 | ||
8 | use strict; | 8 | use strict; |
9 | use Test; | 9 | use Test::More; |
10 | use NPTest; | 10 | use NPTest; |
11 | 11 | ||
12 | use vars qw($tests); | 12 | use vars qw($tests); |
13 | 13 | ||
14 | BEGIN {$tests = 2; plan tests => $tests} | 14 | plan skip_all => "check_mysql not compiled" unless (-x "check_mysql"); |
15 | 15 | ||
16 | my $t; | 16 | plan tests => 3; |
17 | 17 | ||
18 | my $failureOutput = '/Access denied for user: /'; | 18 | my $failureOutput = '/Access denied for user /'; |
19 | my $mysqlserver = getTestParameter( "mysql_server", "NP_MYSQL_SERVER", undef, | ||
20 | "A MySQL Server"); | ||
21 | my $mysql_login_details = getTestParameter( "mysql_login_details", "MYSQL_LOGIN_DETAILS", undef, | ||
22 | "Command line parameters to specify login access"); | ||
19 | 23 | ||
20 | if ( -x "./check_mysql" ) | 24 | my $result; |
21 | { | ||
22 | my $mysqlserver = getTestParameter( "mysql_server", "NP_MYSQL_SERVER", undef, | ||
23 | "A MySQL Server"); | ||
24 | 25 | ||
25 | $t += checkCmd( "./check_mysql -H $mysqlserver -P 3306", 2, $failureOutput ); | 26 | $result = NPTest->testCmd("./check_mysql -H $mysqlserver $mysql_login_details"); |
26 | } | 27 | cmp_ok( $result->return_code, '==', 0, "Login okay"); |
27 | else | 28 | |
28 | { | 29 | $result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy"); |
29 | $t += skipMissingCmd( "./check_mysql", $tests ); | 30 | cmp_ok( $result->return_code, '==', 2, "Login expected failure"); |
30 | } | 31 | like( $result->output, $failureOutput, "Error string as expected"); |
31 | 32 | ||
32 | exit(0) if defined($Test::Harness::VERSION); | ||
33 | exit($tests - $t); | ||