Only output trigger 'scope' if it's set in YAML and JSON producers
[dbsrgits/SQL-Translator.git] / t / 34tt-base.t
1 #!/usr/bin/perl -w
2 # vim:filetype=perl
3
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'
6
7 use strict;
8 use Test::More;
9 use Test::Exception;
10 use Test::SQL::Translator qw(maybe_plan);
11
12 BEGIN {
13     maybe_plan(4, 'Template 2.20',
14                'Test::Differences',
15                'SQL::Translator::Parser::XML::SQLFairy')
16 }
17 use Test::Differences;
18
19 use SQL::Translator;
20 use FindBin qw/$Bin/;
21 # Access to test libs. We want Producer/BaseTest.pm from here.
22 use lib ("$Bin/lib");
23
24
25 # Parse the test XML schema
26 my $obj;
27 $obj = SQL::Translator->new(
28     debug          => 0,
29     show_warnings  => 0,
30     add_drop_table => 1,
31     from           => "XML-SQLFairy",
32     filename       => "$Bin/data/xml/schema.xml",
33     to             => "Producer::BaseTest::produce",
34 );
35 my $out;
36 lives_ok { $out = $obj->translate; }  "Translate ran";
37 is $obj->error, ''                   ,"No errors";
38 ok $out ne ""                        ,"Produced something!";
39 local $/ = undef; # slurp
40 eq_or_diff $out, <DATA>              ,"Output looks right";
41
42
43 __DATA__
44 Hello World
45 Tables: Basic, Another
46
47 Basic
48 ------
49 Fields: id title description email explicitnulldef explicitemptystring emptytagdef another_id timest
50
51 Another
52 ------
53 Fields: id num
54