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