Commit | Line | Data |
76da7994 |
1 | #!/usr/bin/perl |
2 | |
3 | use warnings; |
4 | use strict; |
5 | use Test::More; |
76da7994 |
6 | use FindBin qw/$Bin/; |
76da7994 |
7 | use SQL::Translator; |
8 | |
9 | # Producing a schema with a Translator different from the one the schema was |
10 | # generated should just work. After all the $schema object is just data. |
11 | |
76da7994 |
12 | my $base_file = "$Bin/data/xml/schema.xml"; |
13 | my $base_t = SQL::Translator->new; |
d4cc9bbd |
14 | $base_t->$_(1) for qw/add_drop_table no_comments/; |
76da7994 |
15 | |
16 | # create a base schema attached to $base_t |
d4cc9bbd |
17 | open (my $base_fh, '<', $base_file) or die "$base_file: $!"; |
18 | |
19 | my $base_schema = $base_t->translate( |
76da7994 |
20 | parser => 'XML', |
d4cc9bbd |
21 | data => do { local $/; <$base_fh>; }, |
22 | ) or die $!; |
76da7994 |
23 | |
24 | # now create a new translator and try to feed it the same schema |
25 | my $new_t = SQL::Translator->new; |
d4cc9bbd |
26 | $new_t->$_(1) for qw/add_drop_table no_comments/; |
76da7994 |
27 | |
d4cc9bbd |
28 | my $sql = $new_t->translate( |
f2153a66 |
29 | producer => 'SQLite', |
d4cc9bbd |
30 | data => $base_schema, |
76da7994 |
31 | ); |
32 | |
33 | TODO: { |
34 | local $TODO = 'This will probably not work before the rewrite'; |
35 | |
36 | like ( |
37 | $sql, |
38 | qr/^\s*CREATE TABLE/m, #assume there is at least one create table statement |
39 | "Received some meaningful output from the producer", |
40 | ); |
41 | } |
d4cc9bbd |
42 | |
43 | done_testing; |