From: Robert Bohne Date: Mon, 15 Feb 2010 12:48:13 +0000 (+0100) Subject: Add test for custom_column_info callback X-Git-Tag: 0.05003~5^2~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=457e71af14149fd3d53bb1f0fbb6e124c72f7ae4;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Add test for custom_column_info callback --- diff --git a/t/14ora_common.t b/t/14ora_common.t index 1bbe5f1..be5f692 100644 --- a/t/14ora_common.t +++ b/t/14ora_common.t @@ -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 ) { diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 6f21ba6..191cc0a 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -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;