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