rename vendor tests
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_06sybase_common.t
1 use strict;
2 use lib qw(t/lib);
3 use dbixcsl_common_tests;
4 use Test::More;
5 use Test::Exception;
6 use List::MoreUtils 'apply';
7
8 my $dsn      = $ENV{DBICTEST_SYBASE_DSN} || '';
9 my $user     = $ENV{DBICTEST_SYBASE_USER} || '';
10 my $password = $ENV{DBICTEST_SYBASE_PASS} || '';
11
12 my $tester = dbixcsl_common_tests->new(
13     vendor      => 'sybase',
14     auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY',
15     default_function     => 'getdate()',
16     default_function_def => 'AS getdate()',
17     dsn         => $dsn,
18     user        => $user,
19     password    => $password,
20     data_types  => {
21         # http://ispirer.com/wiki/sqlways/sybase/data-types
22         #
23         # Numeric Types
24         'integer identity' => { data_type => 'integer', is_auto_increment => 1 },
25         int      => { data_type => 'integer' },
26         integer  => { data_type => 'integer' },
27         bigint   => { data_type => 'bigint' },
28         smallint => { data_type => 'smallint' },
29         tinyint  => { data_type => 'tinyint' },
30         'double precision' => { data_type => 'double precision' },
31         real           => { data_type => 'real' },
32         float          => { data_type => 'double precision' },
33         'float(14)'    => { data_type => 'real' },
34         'float(15)'    => { data_type => 'real' },
35         'float(16)'    => { data_type => 'double precision' },
36         'float(48)'    => { data_type => 'double precision' },
37         'numeric(6,3)' => { data_type => 'numeric', size => [6,3] },
38         'decimal(6,3)' => { data_type => 'numeric', size => [6,3] },
39         numeric        => { data_type => 'numeric' },
40         decimal        => { data_type => 'numeric' },
41         bit            => { data_type => 'bit' },
42
43         # Money Types
44         money          => { data_type => 'money' },
45         smallmoney     => { data_type => 'smallmoney' },
46
47         # Computed Column
48         'AS getdate()'     => { data_type => undef, inflate_datetime => 1, default_value => \'getdate()' },
49
50         # Blob Types
51         text     => { data_type => 'text' },
52         unitext  => { data_type => 'unitext' },
53         image    => { data_type => 'image' },
54
55         # DateTime Types
56         date     => { data_type => 'date' },
57         time     => { data_type => 'time' },
58         datetime => { data_type => 'datetime' },
59         smalldatetime  => { data_type => 'smalldatetime' },
60
61         # Timestamp column
62         timestamp      => { data_type => 'timestamp', inflate_datetime => 0 },
63
64         # String Types
65         'char'         => { data_type => 'char', size => 1 },
66         'char(2)'      => { data_type => 'char', size => 2 },
67         'nchar'        => { data_type => 'nchar', size => 1 },
68         'nchar(2)'     => { data_type => 'nchar', size => 2 },
69         'unichar(2)'   => { data_type => 'unichar', size => 2 },
70         'varchar(2)'   => { data_type => 'varchar', size => 2 },
71         'nvarchar(2)'  => { data_type => 'nvarchar', size => 2 },
72         'univarchar(2)' => { data_type => 'univarchar', size => 2 },
73
74         # Binary Types
75         'binary'       => { data_type => 'binary', size => 1 },
76         'binary(2)'    => { data_type => 'binary', size => 2 },
77         'varbinary(2)' => { data_type => 'varbinary', size => 2 },
78     },
79     # test that named constraints aren't picked up as tables (I can't reproduce this on my machine)
80     failtrigger_warnings => [ qr/^Bad table or view 'sybase_loader_test2_ref_slt1'/ ],
81     extra => {
82         create => [
83             q{
84                 CREATE TABLE sybase_loader_test1 (
85                     id int identity primary key
86                 )
87             },
88             q{
89                 CREATE TABLE sybase_loader_test2 (
90                     id int identity primary key,
91                     sybase_loader_test1_id int,
92                     CONSTRAINT sybase_loader_test2_ref_slt1 FOREIGN KEY (sybase_loader_test1_id) REFERENCES sybase_loader_test1 (id)
93                 )
94             },
95         ],
96         drop => [ qw/sybase_loader_test1 sybase_loader_test2/ ],
97     },
98 );
99
100 if( !$dsn || !$user ) {
101     $tester->skip_tests('You need to set the DBICTEST_SYBASE_DSN, _USER, and _PASS environment variables');
102 }
103 else {
104     $tester->run_tests();
105 }
106
107 # vim:et sts=4 sw=4 tw=0: