Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
cb551b07 |
2 | use DBIx::Class::Optional::Dependencies -skip_all_without => 'deploy'; |
3 | |
4068e05f |
4 | use strict; |
5 | use warnings; |
6 | |
7 | use Test::More; |
91d0c99f |
8 | use Test::Exception; |
c0329273 |
9 | |
4068e05f |
10 | use DBICTest; |
e48635f7 |
11 | use DBICTest::Util qw( slurp_bytes rm_rf ); |
12 | use DBIx::Class::_Util 'mkdir_p'; |
4068e05f |
13 | |
37b5ab51 |
14 | local $ENV{DBI_DSN}; |
15 | |
1759f82f |
16 | # this is how maint/gen_schema did it (connect() to force a storage |
17 | # instance, but no conninfo) |
18 | # there ought to be more code like this in the wild |
19 | like( |
20 | DBICTest::Schema->connect->deployment_statements('SQLite'), |
111364b3 |
21 | qr/\bCREATE TABLE artist\b/i # ensure quoting *is* disabled |
1759f82f |
22 | ); |
91d0c99f |
23 | |
24 | lives_ok( sub { |
25 | my $parse_schema = DBICTest->init_schema(no_deploy => 1); |
26 | $parse_schema->deploy({},'t/lib/test_deploy'); |
27 | $parse_schema->resultset("Artist")->all(); |
28 | }, 'artist table deployed correctly' ); |
29 | |
08ac7648 |
30 | my $schema = DBICTest->init_schema( quote_names => 1 ); |
4068e05f |
31 | |
e48635f7 |
32 | my $var_dir = "t/var/ddl_dir-$$/"; |
33 | mkdir_p $var_dir unless -d $var_dir; |
4068e05f |
34 | |
e48635f7 |
35 | my $test_dir_1 = $var_dir . 'test1/foo/bar'; |
36 | rm_rf $test_dir_1 if -d $test_dir_1; |
08ac7648 |
37 | $schema->create_ddl_dir( [qw(SQLite MySQL)], 1, $test_dir_1 ); |
4068e05f |
38 | |
076be7c4 |
39 | ok( -d $test_dir_1, 'create_ddl_dir did a make_path on its target dir' ); |
4068e05f |
40 | ok( scalar( glob $test_dir_1.'/*.sql' ), 'there are sql files in there' ); |
41 | |
08ac7648 |
42 | my $less = $schema->clone; |
43 | $less->unregister_source('BindType'); |
44 | $less->create_ddl_dir( [qw(SQLite MySQL)], 2, $test_dir_1, 1 ); |
45 | |
46 | for ( |
47 | [ SQLite => '"' ], |
48 | [ MySQL => '`' ], |
49 | ) { |
50 | my $type = $_->[0]; |
51 | my $q = quotemeta($_->[1]); |
52 | |
e48635f7 |
53 | for my $f (map { $test_dir_1 . "/DBICTest-Schema-${_}-$type.sql" } qw(1 2) ) { |
54 | like ( |
55 | scalar slurp_bytes $f, |
56 | qr/CREATE TABLE ${q}track${q}/, |
57 | "Proper quoting in $f" |
58 | ); |
08ac7648 |
59 | } |
60 | |
61 | { |
62 | local $TODO = 'SQLT::Producer::MySQL has no knowledge of the mythical beast of quoting...' |
63 | if $type eq 'MySQL'; |
64 | |
e48635f7 |
65 | my $f = $test_dir_1 . "/DBICTest-Schema-1-2-$type.sql"; |
66 | like ( |
67 | scalar slurp_bytes $f, |
68 | qr/DROP TABLE ${q}bindtype_test${q}/, |
69 | "Proper quoting in diff $f" |
70 | ); |
08ac7648 |
71 | } |
72 | } |
73 | |
4ca1fd6f |
74 | { |
75 | local $TODO = 'we should probably add some tests here for actual deployability of the DDL?'; |
76 | ok( 0 ); |
4068e05f |
77 | } |
78 | |
8d6b1478 |
79 | END { |
e48635f7 |
80 | rm_rf $var_dir; |
8d6b1478 |
81 | } |
82 | |
4068e05f |
83 | done_testing; |