X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F15sybase_common.t;h=903592f6ba54c5552f68f4c5145054c0badd0938;hb=2d1dc6de7c39309d9a4e8298ecaace25ac749ad6;hp=f0e5f4c9163bc0b67043a7ea11a05e0f3f91f78d;hpb=1e1839d194d3713344fa716408b4fcf351396b48;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/15sybase_common.t b/t/15sybase_common.t index f0e5f4c..903592f 100644 --- a/t/15sybase_common.t +++ b/t/15sybase_common.t @@ -1,17 +1,94 @@ use strict; use lib qw(t/lib); use dbixcsl_common_tests; +use Test::More; +use Test::Exception; my $dsn = $ENV{DBICTEST_SYBASE_DSN} || ''; my $user = $ENV{DBICTEST_SYBASE_USER} || ''; my $password = $ENV{DBICTEST_SYBASE_PASS} || ''; my $tester = dbixcsl_common_tests->new( - vendor => 'Sybase', + vendor => 'sybase', auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY', dsn => $dsn, user => $user, password => $password, + extra => { + create => [ + q{ + CREATE TABLE sybase_loader_test1 ( + id INTEGER IDENTITY NOT NULL PRIMARY KEY, + ts timestamp, + charfield VARCHAR(10) DEFAULT 'foo', + computed_dt AS getdate() + ) + }, + ], + drop => [ qw/ sybase_loader_test1 / ], + count => 9, + run => sub { + my ($schema, $monikers, $classes) = @_; + + my $rs = $schema->resultset($monikers->{sybase_loader_test1}); + my $rsrc = $rs->result_source; + + is $rsrc->column_info('id')->{data_type}, + 'numeric', + 'INTEGER IDENTITY data_type is correct'; + + is $rsrc->column_info('id')->{is_auto_increment}, + 1, + 'INTEGER IDENTITY is_auto_increment => 1'; + + { + local $TODO = 'timestamp introspection broken'; + + is $rsrc->column_info('ts')->{data_type}, + 'timestamp', + 'timestamps have the correct data_type'; + } + + is $rsrc->column_info('charfield')->{data_type}, + 'varchar', + 'VARCHAR has correct data_type'; + + { + local $TODO = 'constant DEFAULT introspection'; + + is $rsrc->column_info('charfield')->{default_value}, + 'foo', + 'constant DEFAULT is correct'; + } + + is $rsrc->column_info('charfield')->{size}, + 10, + 'VARCHAR(10) has correct size'; + + ok ((exists $rsrc->column_info('computed_dt')->{data_type} + && (not defined $rsrc->column_info('computed_dt')->{data_type})), + 'data_type for computed column exists and is undef') + or diag "Data type is: ", + $rsrc->column_info('computed_dt')->{data_type} + ; + + { + local $TODO = 'default_value for computed columns'; + + my $computed_dt_default = + $rsrc->column_info('computed_dt')->{default_value}; + + ok ((ref $computed_dt_default eq 'SCALAR'), + 'default_value for computed column is a scalar ref') +# or diag "default_value is: ", $computed_dt_default + ; + + eval { is $$computed_dt_default, + 'getdate()', + 'default_value for computed column is correct' }; + } + }, + }, ); if( !$dsn || !$user ) {