Add test for custom_column_info callback
Robert Bohne [Mon, 15 Feb 2010 12:48:13 +0000 (13:48 +0100)]
t/14ora_common.t
t/lib/dbixcsl_common_tests.pm

index 1bbe5f1..be5f692 100644 (file)
@@ -8,8 +8,18 @@ my $dsn      = $ENV{DBICTEST_ORA_DSN} || '';
 my $user     = $ENV{DBICTEST_ORA_USER} || '';
 my $password = $ENV{DBICTEST_ORA_PASS} || '';
 
+sub _custom_column_info {
+    my $info = shift;
+
+    if ( $info->{TYPE_NAME} eq 'DATE' ){
+        return { timezone => "Europe/Berlin" };
+    }
+    return;
+}
+
 my $tester = dbixcsl_common_tests->new(
     vendor      => 'Oracle',
+    custom_column_info => \&_custom_column_info,
     auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY',
     auto_inc_cb => sub {
         my ($table, $col) = @_;
@@ -32,6 +42,33 @@ my $tester = dbixcsl_common_tests->new(
     dsn         => $dsn,
     user        => $user,
     password    => $password,
+    extra => {
+        create => [qq{
+            CREATE TABLE oracle_loader_test1 (
+                id number(5) NOT NULL,
+                name varchar2(100) NOT NULL,
+                create_date date NOT NULL,
+                modification_date date,
+                PRIMARY KEY (id)
+            )
+        },],
+        drop  => [qw/ oracle_loader_test1 /],
+        count => 2,
+        run   => sub {
+            my ( $schema, $monikers, $classes ) = @_;
+            my $rs = $schema->resultset( $monikers->{oracle_loader_test1} );
+
+            is $rs->result_source->column_info('create_date')->{timezone},
+                'Europe/Berlin',
+                'create_date hast timezone';
+
+            is $rs->result_source->column_info('modification_date')->{timezone},
+                'Europe/Berlin',
+                'modification_date hast timezone';
+
+        },
+      }
+
 );
 
 if( !$dsn || !$user ) {
index 6f21ba6..191cc0a 100644 (file)
@@ -108,6 +108,7 @@ sub setup_schema {
     );
 
     $loader_opts{db_schema} = $self->{db_schema} if $self->{db_schema};
+    $loader_opts{custom_column_info} = $self->{custom_column_info} if $self->{custom_column_info};
 
     {
        my @loader_warnings;