[Bps-public-commit] dbix-searchbuilder branch, skip-tz-tests-in-some-cases, created. 1.63_01-2-gff69641

Ruslan Zakirov ruz at bestpractical.com
Mon Apr 1 11:55:31 EDT 2013


The branch, skip-tz-tests-in-some-cases has been created
        at  ff696413d6f8ec00d81088e4046d6f3d0c68fc44 (commit)

- Log -----------------------------------------------------------------
commit cc86c81f58da12de1334b08e8d6717fc59505540
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Apr 1 18:30:07 2013 +0400

    skip timezone tests on SQLite when tzinfo is not there
    
    if system's timezone information is not around then
    timezones tests fails for SQLite

diff --git a/t/02records_datetime.t b/t/02records_datetime.t
index ed5df74..9581405 100644
--- a/t/02records_datetime.t
+++ b/t/02records_datetime.t
@@ -14,6 +14,7 @@ my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
 plan tests => $total;
 
 my $handle;
+my $skip_tz_tests = 0;
 
 foreach my $d ( @AvailableDrivers ) {
 SKIP: {
@@ -42,6 +43,12 @@ SKIP: {
     is( $handle->ConvertTimezoneFunction( Field => '?' ), '?', 'no To argument' );
     is( $handle->ConvertTimezoneFunction( To => 'utc', Field => '?' ), '?', 'From and To equal' );
 
+    if ( $d eq 'SQLite' ) {
+        my $check = '2013-04-01 16:00:00';
+        my ($got) = $handle->dbh->selectrow_array("SELECT datetime(?,'localtime')", undef, $check);
+        $skip_tz_tests = 1 if $got eq $check;
+    }
+
     foreach my $type ('date time', 'DateTime', 'date_time', 'Date-Time') {
         run_test(
             { Type => $type },
@@ -231,27 +238,32 @@ sub run_test {
     my $props = shift;
     my $expected = shift;
 
-    my $users = TestApp::Users->new( $handle );
-    $users->UnLimit;
-    $users->Column( FIELD => 'Expires' );
-    my $column = $users->Column(
-        ALIAS => 'main',
-        FIELD => 'Expires',
-        FUNCTION => $users->_Handle->DateTimeFunction( %$props ),
-    );
-
-    my %got;
-    while ( my $user = $users->Next ) {
-        $got{ $user->Expires || '' } = $user->__Value( $column );
-    }
-    foreach my $key ( keys %got ) {
-        delete $got{ $key } unless exists $expected->{ $key };
+    SKIP: {
+        skip "skipping timezone tests", 1
+            if $props->{'Timezone'} && $skip_tz_tests;
+
+        my $users = TestApp::Users->new( $handle );
+        $users->UnLimit;
+        $users->Column( FIELD => 'Expires' );
+        my $column = $users->Column(
+            ALIAS => 'main',
+            FIELD => 'Expires',
+            FUNCTION => $users->_Handle->DateTimeFunction( %$props ),
+        );
 
-        $got{ $key } =~ s/^0+(?!$)// if defined $got{ $key };
+        my %got;
+        while ( my $user = $users->Next ) {
+            $got{ $user->Expires || '' } = $user->__Value( $column );
+        }
+        foreach my $key ( keys %got ) {
+            delete $got{ $key } unless exists $expected->{ $key };
+
+            $got{ $key } =~ s/^0+(?!$)// if defined $got{ $key };
+        }
+        local $Test::Builder::Level = $Test::Builder::Level + 1;
+        is_deeply( \%got, $expected, "correct ". $props->{'Type'} ." function" )
+            or diag "wrong SQL: ". $users->BuildSelectQuery;
     }
-    local $Test::Builder::Level = $Test::Builder::Level + 1;
-    is_deeply( \%got, $expected, "correct ". $props->{'Type'} ." function" )
-        or diag "wrong SQL: ". $users->BuildSelectQuery;
 }
 
 1;

commit ff696413d6f8ec00d81088e4046d6f3d0c68fc44
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Apr 1 19:53:35 2013 +0400

    skip tests if mysql can not do timezones

diff --git a/t/02records_datetime.t b/t/02records_datetime.t
index 9581405..cba4403 100644
--- a/t/02records_datetime.t
+++ b/t/02records_datetime.t
@@ -48,6 +48,13 @@ SKIP: {
         my ($got) = $handle->dbh->selectrow_array("SELECT datetime(?,'localtime')", undef, $check);
         $skip_tz_tests = 1 if $got eq $check;
     }
+    elsif ($d eq 'mysql') {
+        my $check = '2013-04-01 16:00:00';
+        my ($got) = $handle->dbh->selectrow_array(
+            "SELECT CONVERT_TZ(?, ?, ?)", undef, $check, 'UTC', 'Europe/Moscow'
+        );
+        $skip_tz_tests = 1 if !$got || $got eq $check;
+    }
 
     foreach my $type ('date time', 'DateTime', 'date_time', 'Date-Time') {
         run_test(

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list