|
#!/usr/bin/perl -w
BEGIN {
maybe_plan(6,
'SQL::Translator::Parser::XML::SQLFairy' ,
'Template 2.20' ,
'Test::Differences'
);
}
{
my $obj ;
$obj = SQL::Translator->new(
show_warnings => 0,
from => "XML-SQLFairy" ,
filename => "$Bin/data/xml/schema.xml" ,
to => "TTSchema" ,
producer_args => {
ttfile => "$Bin/data/template/basic.tt" ,
tt_vars => {
foo => 'bar' ,
hello => 'world' ,
},
},
);
my $out ;
lives_ok { $out = $obj ->translate; } "Translate ran" ;
ok $out ne "" , "Produced something!" ;
eq_or_diff
$out ,
do { local ( @ARGV , $/) = "$Bin/data/template/testresult_basic.txt" ; <> },
"Output looks right"
;
}
{
my $tmpl = q{
[%- FOREACH table = schema.get_tables %]
Table: $table
[%- END %]} ;
my $obj ;
$obj = SQL::Translator->new(
show_warnings => 0,
from => "XML-SQLFairy" ,
filename => "$Bin/data/xml/schema.xml" ,
to => "TTSchema" ,
producer_args => {
ttfile => \ $tmpl ,
tt_conf => {
INTERPOLATE => 1,
},
tt_vars => {
foo => 'bar' ,
hello => 'world' ,
},
},
);
my $out ;
lives_ok { $out = $obj ->translate; } "Translate ran" ;
ok $out ne "" , "Produced something!" ;
local $/ = undef ;
eq_or_diff $out , q{
Table: Basic
Table: Another}
, "Output looks right" ;
}
|