]> git.decadent.org.uk Git - maypole.git/blobdiff - t/db_colinfo.t
fixed mysql test in db_colinfo to skip if no MySQL DBD driver
[maypole.git] / t / db_colinfo.t
index 471d05986906b9be754d0462131088471fbbd909..c56fbf28497b2b954345059a1d6816474574885d 100755 (executable)
@@ -88,24 +88,28 @@ package main;
 
 $DB_Class = 'BeerDB::BeerTestmysql';
 
-my $drh = DBI->install_driver("mysql");
-my %databases = map { $_ => 1 } $drh->func('localhost', 3306, '_ListDBs');
+my $drh = eval { DBI->install_driver("mysql"); };
+$err = $@;
+if ($err) {
+  $skip_msg = "no driver for MySQL";
+} else {
+  my %databases = map { $_ => 1 } $drh->func('localhost', 3306, '_ListDBs');
 
-unless ($databases{test}) {
-  my $rc = $drh->func("createdb", 'test', 'admin');
-}
+  unless ($databases{test}) {
+    my $rc = $drh->func("createdb", 'test', 'admin');
+  }
 
-%databases = map { $_ => 1 } $drh->func('localhost', 3306, '_ListDBs');
+  %databases = map { $_ => 1 } $drh->func('localhost', 3306, '_ListDBs');
 
-if ($databases{test}) {
-  eval {$DB_Class->connection("dbi:mysql:$db", "$dbuser", "$dbpasswd"); };
-  $err = $@;
-  $skip_msg = "Could not connect to MySQL using database 'test', username 'test', and password ''. Check privileges and try again.";
-} else {
-  $err = 'no test db';
-  $skip_msg = "Could not connect to MySQL using database 'test' as it doesn't exist, sorry";
+  if ($databases{test}) {
+    eval {$DB_Class->connection("dbi:mysql:$db", "$dbuser", "$dbpasswd"); };
+    $err = $@;
+    $skip_msg = "Could not connect to MySQL using database 'test', username 'test', and password ''. Check privileges and try again.";
+  } else {
+    $err = 'no test db';
+    $skip_msg = "Could not connect to MySQL using database 'test' as it doesn't exist, sorry";
+  }
 }
-
 $skip_howmany = 22;
 
 SKIP: {