added two tables, so up the number expected
[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 FindBin qw/$Bin/;
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
12 my $base_file = "$Bin/data/xml/schema.xml";
13 my $base_t = SQL::Translator->new;
14 $base_t->$_(1) for qw/add_drop_table no_comments/;
15
16 # create a base schema attached to $base_t
17 open (my $base_fh, '<', $base_file) or die "$base_file: $!";
18
19 my $base_schema = $base_t->translate(
20   parser => 'XML',
21   data => do { local $/; <$base_fh>; },
22 ) or die $!;
23
24 # now create a new translator and try to feed it the same schema
25 my $new_t = SQL::Translator->new;
26 $new_t->$_(1) for qw/add_drop_table no_comments/;
27
28 my $sql = $new_t->translate(
29   producer => 'SQLite',
30   data => $base_schema,
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 }
42
43 done_testing;