aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Ton Voon <tonvoon@users.sourceforge.net> 2005-11-09 17:27:36 +0000
committerGravatar Ton Voon <tonvoon@users.sourceforge.net> 2005-11-09 17:27:36 +0000
commit15330698d4294d428e10a38aa8e82207e57272d1 (patch)
tree8dd6c15c6a98e99bde350d46ba0b0170dfbadcfe /plugins
parent6224ec31587dc70b21b487a57d59cb863c2cd3a8 (diff)
downloadmonitoring-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')
-rw-r--r--plugins/t/check_mysql.t31
1 files changed, 15 insertions, 16 deletions
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t
index ad423595..b29c5c6a 100644
--- a/plugins/t/check_mysql.t
+++ b/plugins/t/check_mysql.t
@@ -6,28 +6,27 @@
#
use strict;
-use Test;
+use Test::More;
use NPTest;
use vars qw($tests);
-BEGIN {$tests = 2; plan tests => $tests}
+plan skip_all => "check_mysql not compiled" unless (-x "check_mysql");
-my $t;
+plan tests => 3;
-my $failureOutput = '/Access denied for user: /';
+my $failureOutput = '/Access denied for user /';
+my $mysqlserver = getTestParameter( "mysql_server", "NP_MYSQL_SERVER", undef,
+ "A MySQL Server");
+my $mysql_login_details = getTestParameter( "mysql_login_details", "MYSQL_LOGIN_DETAILS", undef,
+ "Command line parameters to specify login access");
-if ( -x "./check_mysql" )
-{
- my $mysqlserver = getTestParameter( "mysql_server", "NP_MYSQL_SERVER", undef,
- "A MySQL Server");
+my $result;
- $t += checkCmd( "./check_mysql -H $mysqlserver -P 3306", 2, $failureOutput );
-}
-else
-{
- $t += skipMissingCmd( "./check_mysql", $tests );
-}
+$result = NPTest->testCmd("./check_mysql -H $mysqlserver $mysql_login_details");
+cmp_ok( $result->return_code, '==', 0, "Login okay");
+
+$result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy");
+cmp_ok( $result->return_code, '==', 2, "Login expected failure");
+like( $result->output, $failureOutput, "Error string as expected");
-exit(0) if defined($Test::Harness::VERSION);
-exit($tests - $t);