Commit | Line | Data |
a78e3fed |
1 | use strict; |
c2849787 |
2 | use lib qw(t/lib); |
fbd83464 |
3 | use dbixcsl_common_tests; |
8fdd52a2 |
4 | use Test::More; |
a78e3fed |
5 | |
9e978a19 |
6 | my $dsn = $ENV{DBICTEST_MYSQL_DSN} || ''; |
7 | my $user = $ENV{DBICTEST_MYSQL_USER} || ''; |
8 | my $password = $ENV{DBICTEST_MYSQL_PASS} || ''; |
9 | my $test_innodb = $ENV{DBICTEST_MYSQL_INNODB} || 0; |
a78e3fed |
10 | |
9e978a19 |
11 | my $skip_rels_msg = 'You need to set the DBICTEST_MYSQL_INNODB environment variable to test relationships'; |
a78e3fed |
12 | |
fbd83464 |
13 | my $tester = dbixcsl_common_tests->new( |
52bf3f26 |
14 | vendor => 'Mysql', |
15 | auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT', |
16 | innodb => $test_innodb ? q{Engine=InnoDB} : 0, |
17 | dsn => $dsn, |
18 | user => $user, |
19 | password => $password, |
309e2aa1 |
20 | connect_info_opts=> { on_connect_call => 'set_strict_mode' }, |
52bf3f26 |
21 | skip_rels => $test_innodb ? 0 : $skip_rels_msg, |
22 | no_inline_rels => 1, |
23 | no_implicit_rels => 1, |
8fdd52a2 |
24 | extra => { |
25 | create => [ |
26 | qq{ |
27 | CREATE TABLE mysql_loader_test1 ( |
46bef65f |
28 | id INTEGER UNSIGNED NOT NULL PRIMARY KEY, |
29 | value ENUM('foo', 'bar', 'baz') |
8fdd52a2 |
30 | ) |
31 | }, |
e0699cd9 |
32 | qq{ |
33 | CREATE TABLE mysql_loader_test2 ( |
34 | id INTEGER UNSIGNED NOT NULL PRIMARY KEY, |
3facc532 |
35 | somets TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP |
e0699cd9 |
36 | ) |
37 | }, |
8fdd52a2 |
38 | ], |
e0699cd9 |
39 | drop => [ qw/ mysql_loader_test1 mysql_loader_test2 / ], |
40 | count => 5, |
8fdd52a2 |
41 | run => sub { |
42 | my ($schema, $monikers, $classes) = @_; |
43 | |
44 | my $rs = $schema->resultset($monikers->{mysql_loader_test1}); |
45 | my $column_info = $rs->result_source->column_info('id'); |
46bef65f |
46 | |
8fdd52a2 |
47 | is($column_info->{extra}->{unsigned}, 1, 'Unsigned MySQL columns'); |
46bef65f |
48 | |
49 | $column_info = $rs->result_source->column_info('value'); |
50 | |
51 | like($column_info->{data_type}, qr/^enum$/i, 'MySQL ENUM type'); |
52 | is_deeply($column_info->{extra}->{list}, [qw/foo bar baz/], |
53 | 'MySQL ENUM values'); |
e0699cd9 |
54 | |
55 | $rs = $schema->resultset($monikers->{mysql_loader_test2}); |
3facc532 |
56 | $column_info = $rs->result_source->column_info('somets'); |
1d27214f |
57 | my $default = $column_info->{default_value}; |
58 | ok ((ref($default) eq 'SCALAR'), |
59 | 'CURRENT_TIMESTAMP default_value is a scalar ref'); |
e0699cd9 |
60 | like $$default, qr/^CURRENT_TIMESTAMP\z/i, |
61 | 'CURRENT_TIMESTAMP default eq "CURRENT_TIMESTAMP"'; |
8fdd52a2 |
62 | }, |
63 | } |
a78e3fed |
64 | ); |
65 | |
9e978a19 |
66 | if( !$dsn || !$user ) { |
67 | $tester->skip_tests('You need to set the DBICTEST_MYSQL_DSN, _USER, and _PASS environment variables'); |
a78e3fed |
68 | } |
69 | else { |
70 | $tester->run_tests(); |
71 | } |