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