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