added two tables, so up the number expected
[dbsrgits/SQL-Translator-2.0-ish.git] / t / 61translator_agnostic.t
CommitLineData
76da7994 1#!/usr/bin/perl
2
3use warnings;
4use strict;
5use Test::More;
76da7994 6use FindBin qw/$Bin/;
76da7994 7use 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 12my $base_file = "$Bin/data/xml/schema.xml";
13my $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 17open (my $base_fh, '<', $base_file) or die "$base_file: $!";
18
19my $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
25my $new_t = SQL::Translator->new;
d4cc9bbd 26$new_t->$_(1) for qw/add_drop_table no_comments/;
76da7994 27
d4cc9bbd 28my $sql = $new_t->translate(
f2153a66 29 producer => 'SQLite',
d4cc9bbd 30 data => $base_schema,
76da7994 31);
32
33TODO: {
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
43done_testing;