Display a warning when an ODBC or ADO subclass is not found
[dbsrgits/DBIx-Class.git] / t / inflate / datetime_mssql.t
index 3c425e7..cff0fba 100644 (file)
@@ -17,14 +17,16 @@ BEGIN {
   }
 }
 
-my ($dsn, $user, $pass)    = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PASS/};
+my ($dsn,  $user,  $pass)  = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PASS/};
 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSSQL_${_}" }      qw/DSN USER PASS/};
+my ($dsn3, $user3, $pass3) = @ENV{map { "DBICTEST_MSSQL_ADO_${_}" }  qw/DSN USER PASS/};
 
-if (not ($dsn || $dsn2)) {
+if (not ($dsn || $dsn2 || $dsn3)) {
   plan skip_all =>
-    'Set $ENV{DBICTEST_MSSQL_ODBC_DSN} and/or $ENV{DBICTEST_MSSQL_DSN} _USER '
-    .'and _PASS to run this test' .
-    "\nWarning: This test drops and creates a table called 'small_dt'";
+    'Set $ENV{DBICTEST_MSSQL_ODBC_DSN} and/or $ENV{DBICTEST_MSSQL_DSN} and/or '
+    .'$ENV{DBICTEST_MSSQL_ADO_DSN} _USER and _PASS to run this test' .
+    "\nWarning: This test drops and creates tables called 'event_small_dt' and"
+    ." 'track'.";
 }
 
 plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt')
@@ -33,6 +35,7 @@ plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missin
 my @connect_info = (
   [ $dsn,  $user,  $pass ],
   [ $dsn2, $user2, $pass2 ],
+  [ $dsn3, $user3, $pass3 ],
 );
 
 my $schema;
@@ -58,7 +61,8 @@ for my $connect_info (@connect_info) {
 
   my $guard = Scope::Guard->new(\&cleanup);
 
-  try { $schema->storage->dbh->do("DROP TABLE track") };
+  # $^W because DBD::ADO is a piece of crap
+  try { local $^W = 0; $schema->storage->dbh->do("DROP TABLE track") };
   $schema->storage->dbh->do(<<"SQL");
 CREATE TABLE track (
  trackid INT IDENTITY PRIMARY KEY,
@@ -67,7 +71,7 @@ CREATE TABLE track (
  last_updated_at DATETIME,
 )
 SQL
-  try { $schema->storage->dbh->do("DROP TABLE event_small_dt") };
+  try { local $^W = 0; $schema->storage->dbh->do("DROP TABLE event_small_dt") };
   $schema->storage->dbh->do(<<"SQL");
 CREATE TABLE event_small_dt (
  id INT IDENTITY PRIMARY KEY,
@@ -108,6 +112,8 @@ SQL
   for my $dt_type (@dt_types) {
     my ($type, $col, $source, $pk, $create_extra, $sample_dt) = @$dt_type;
 
+    delete $sample_dt->{nanosecond} if $dsn =~ /:ADO:/;
+
     ok(my $dt = DateTime->new($sample_dt));
 
     my $row;