[Nagiosplug-checkins] nagiosplug/plugins/t check_mysql.t,1.3,1.4
Ton Voon
tonvoon at users.sourceforge.net
Wed Nov 9 09:30:58 CET 2005
Update of /cvsroot/nagiosplug/nagiosplug/plugins/t
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9349/t
Modified Files:
check_mysql.t
Log Message:
Using Test::More
Index: check_mysql.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_mysql.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- check_mysql.t 25 Jul 2005 01:47:14 -0000 1.3
+++ check_mysql.t 9 Nov 2005 17:27:36 -0000 1.4
@@ -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);
More information about the Commits
mailing list