Massive cleanup of DateTime test dependencies, other interim
[dbsrgits/DBIx-Class.git] / t / inflate / datetime_mssql.t
index c1ce5dd..e9c003e 100644 (file)
@@ -1,5 +1,5 @@
 use strict;
-use warnings;  
+use warnings;
 
 use Test::More;
 use Test::Exception;
@@ -22,13 +22,11 @@ if (not ($dsn || $dsn2)) {
     '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 'track'";
-} else {
-  eval "use DateTime; use DateTime::Format::Strptime;";
-  if ($@) {
-    plan skip_all => 'needs DateTime and DateTime::Format::Strptime for testing';
-  }
 }
 
+plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt')
+  unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt');
+
 my @connect_info = (
   [ $dsn,  $user,  $pass ],
   [ $dsn2, $user2, $pass2 ],
@@ -36,6 +34,7 @@ my @connect_info = (
 
 my $schema;
 
+SKIP:
 for my $connect_info (@connect_info) {
   my ($dsn, $user, $pass) = @$connect_info;
 
@@ -45,6 +44,15 @@ for my $connect_info (@connect_info) {
     on_connect_call => 'datetime_setup'
   });
 
+  {
+    my $w;
+    local $SIG{__WARN__} = sub { $w = shift };
+    $schema->storage->ensure_connected;
+    if ($w =~ /Your DBD::Sybase is too old to support DBIx::Class::InflateColumn::DateTime/) {
+      skip "Skipping tests on old DBD::Sybase " . DBD::Sybase->VERSION, 1;
+    }
+  }
+
   my $guard = Scope::Guard->new(\&cleanup);
 
 # coltype, column, datehash
@@ -95,8 +103,8 @@ SQL
       ->first
     );
     is( $row->$col, $dt, "$type roundtrip" );
-    
-    is( $row->$col->nanosecond, $sample_dt->{nanosecond},
+
+    cmp_ok( $row->$col->nanosecond, '==', $sample_dt->{nanosecond},
       'DateTime fractional portion roundtrip' )
       if exists $sample_dt->{nanosecond};
   }