4 # Before `make install' is performed this script should be runnable with
5 # `make test'. After `make install' it should work as `perl test.pl'
11 BEGIN { our %opt; map { $opt{$_}=1 if s/^-// } @ARGV; }
12 use constant DEBUG => (exists $opt{d} ? 1 : 0);
13 local $SIG{__WARN__} = sub { diag "[warn] ", @_; };
18 #=============================================================================
20 eval { require Template; };
21 if ($@ && $@ =~ m!locate Template.pm in!) {
22 plan skip_all => "You need Template Toolkit to run this test.";
24 eval { require Test::Differences; };
25 if ($@ && $@ =~ m!locate Test/Differences.pm in!) {
26 plan skip_all => "You need Test::Differences for this test.";
28 use Test::Differences;
32 use SQL::Translator::Producer::TTSchema;
34 # Parse the test XML schema
36 $obj = SQL::Translator->new(
37 debug => DEBUG, #$opt{d},
41 filename => "$Bin/data/xml/schema-basic.xml",
44 ttfile => "$Bin/data/template/basic.tt",
48 lives_ok { $out = $obj->translate; } "Translate ran";
49 ok $out ne "" ,"Produced something!";
50 local $/ = undef; # slurp
51 eq_or_diff $out, <DATA> ,"Output looks right";
52 # I'm not sure if this diff is the best test, it is probaly too sensitive. But
53 # it at least it will blow up if anything changes!
56 #print "Debug:", Dumper($obj) if DEBUG;
63 ==========================================================================
75 foreign_key_reference:
90 foreign_key_reference:
105 foreign_key_reference:
120 foreign_key_reference:
135 foreign_key_reference:
150 foreign_key_reference:
165 foreign_key_reference: