1use strict;
2use warnings;
3
4use Test::More ;
5use DBI;
6$|= 1;
7
8use vars qw($test_user $test_password $test_db $test_dsn);
9use lib 't', '.';
10require 'lib.pl';
11
12# remove database from DSN
13$test_dsn =~ s/^DBI:mysql:([^:;]+)([:;]?)/DBI:mysql:$2/;
14
15my $dbh;
16eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
17                      { RaiseError => 1, PrintError => 1, AutoCommit => 0 });};
18if ($@) {
19    diag $@;
20    plan skip_all => "no database connection";
21}
22plan tests => 2;
23
24ok defined $dbh, "Connected to database";
25eval{ $dbh->do("CREATE DATABASE IF NOT EXISTS $test_db") };
26if($@) {
27    diag "No permission to '$test_db' database on '$test_dsn' for user '$test_user'";
28} else {
29    diag "Database '$test_db' accessible";
30}
31
32ok $dbh->disconnect();
33