Release commit for 1.62
[dbsrgits/SQL-Translator.git] / t / 61translator_agnostic.t
CommitLineData
cbceab6a 1#!/usr/bin/perl
2
3use warnings;
4use strict;
9f25d3c5 5use Test::More;
6use Test::SQL::Translator;
cbceab6a 7use FindBin qw/$Bin/;
8
9f25d3c5 9BEGIN {
10 maybe_plan(1, 'SQL::Translator::Parser::XML',
11 'SQL::Translator::Producer::XML');
12}
13
cbceab6a 14use 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
20my $base_file = "$Bin/data/xml/schema.xml";
21my $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
25my $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
31my $new_t = SQL::Translator->new;
32$new_t->$_ (1) for qw/add_drop_table no_comments/;
33
34my $sql = $new_t->translate (
35 data => $base_schema,
36 producer => 'SQLite'
37);
38
e0d2b70b 39TODO: {
40 local $TODO = 'This will probably not work before the rewrite';
41
42 like (
43 $sql,
aee4b66e 44 qr/^\s*CREATE TABLE/m, #assume there is at least one create table statement
e0d2b70b 45 "Received some meaningful output from the producer",
46 );
47}