a couple more extra TODO tests for Sybase computed columns
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 15sybase_common.t
CommitLineData
fe67d343 1use strict;
2use lib qw(t/lib);
3use dbixcsl_common_tests;
804c115d 4use Test::More;
2d1dc6de 5use Test::Exception;
f9f65ded 6
fe67d343 7my $dsn = $ENV{DBICTEST_SYBASE_DSN} || '';
8my $user = $ENV{DBICTEST_SYBASE_USER} || '';
9my $password = $ENV{DBICTEST_SYBASE_PASS} || '';
10
11my $tester = dbixcsl_common_tests->new(
7cb9244f 12 vendor => 'sybase',
fe67d343 13 auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY',
14 dsn => $dsn,
15 user => $user,
16 password => $password,
804c115d 17 extra => {
18 create => [
19 q{
20 CREATE TABLE sybase_loader_test1 (
21 id INTEGER IDENTITY NOT NULL PRIMARY KEY,
de82711a 22 ts timestamp,
23 charfield VARCHAR(10) DEFAULT 'foo',
24 computed_dt AS getdate()
804c115d 25 )
26 },
27 ],
28 drop => [ qw/ sybase_loader_test1 / ],
2d1dc6de 29 count => 9,
804c115d 30 run => sub {
31 my ($schema, $monikers, $classes) = @_;
32
33 my $rs = $schema->resultset($monikers->{sybase_loader_test1});
de82711a 34 my $rsrc = $rs->result_source;
35
36 is $rsrc->column_info('id')->{data_type},
37 'numeric',
38 'INTEGER IDENTITY data_type is correct';
39
40 is $rsrc->column_info('id')->{is_auto_increment},
41 1,
42 'INTEGER IDENTITY is_auto_increment => 1';
804c115d 43
44 {
45 local $TODO = 'timestamp introspection broken';
46
de82711a 47 is $rsrc->column_info('ts')->{data_type},
804c115d 48 'timestamp',
49 'timestamps have the correct data_type';
50 }
de82711a 51
52 is $rsrc->column_info('charfield')->{data_type},
53 'varchar',
54 'VARCHAR has correct data_type';
55
56 {
57 local $TODO = 'constant DEFAULT introspection';
58
2d1dc6de 59 is $rsrc->column_info('charfield')->{default_value},
de82711a 60 'foo',
61 'constant DEFAULT is correct';
62 }
63
64 is $rsrc->column_info('charfield')->{size},
65 10,
66 'VARCHAR(10) has correct size';
67
db4d62ad 68 ok ((exists $rsrc->column_info('computed_dt')->{data_type}
69 && (not defined $rsrc->column_info('computed_dt')->{data_type})),
70 'data_type for computed column exists and is undef')
71 or diag "Data type is: ",
72 $rsrc->column_info('computed_dt')->{data_type}
73 ;
2d1dc6de 74
75 {
76 local $TODO = 'default_value for computed columns';
77
78 my $computed_dt_default =
79 $rsrc->column_info('computed_dt')->{default_value};
80
81 ok ((ref $computed_dt_default eq 'SCALAR'),
82 'default_value for computed column is a scalar ref')
83# or diag "default_value is: ", $computed_dt_default
84 ;
85
86 eval { is $$computed_dt_default,
87 'getdate()',
88 'default_value for computed column is correct' };
89 }
804c115d 90 },
91 },
fe67d343 92);
93
94if( !$dsn || !$user ) {
95 $tester->skip_tests('You need to set the DBICTEST_SYBASE_DSN, _USER, and _PASS environment variables');
96}
97else {
98 $tester->run_tests();
99}