[Bps-public-commit] dbix-searchbuilder branch, skip-tz-tests-in-some-cases, created. 1.63_01-2-g35d9a5a
Ruslan Zakirov
ruz at bestpractical.com
Wed Apr 17 11:04:43 EDT 2013
The branch, skip-tz-tests-in-some-cases has been created
at 35d9a5a82fb73d0231fd2f37a52cf01c036484d7 (commit)
- Log -----------------------------------------------------------------
commit 14ce2c54c4cb87888797919c8e2e8e11d73ba060
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..19ae9e4 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;
foreach my $d ( @AvailableDrivers ) {
SKIP: {
@@ -42,6 +43,13 @@ SKIP: {
is( $handle->ConvertTimezoneFunction( Field => '?' ), '?', 'no To argument' );
is( $handle->ConvertTimezoneFunction( To => 'utc', Field => '?' ), '?', 'From and To equal' );
+ $skip_tz_tests = 0;
+ 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 +239,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 35d9a5a82fb73d0231fd2f37a52cf01c036484d7
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 19ae9e4..f1a0d7a 100644
--- a/t/02records_datetime.t
+++ b/t/02records_datetime.t
@@ -49,6 +49,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