XML test src changed name.
[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 use Data::Dumper;
13 use vars '%opt';
14 BEGIN { map { $opt{$_}=1 if s/^-// } @ARGV; }
15 use constant DEBUG => (exists $opt{d} ? 1 : 0);
16
17 use FindBin qw/$Bin/;
18 use lib ("$Bin/lib");
19
20 # Testing 1,2,3,4...
21 #=============================================================================
22 package main;
23
24 BEGIN {
25     maybe_plan(4, 'Template', 'Test::Differences')
26 }
27 use Test::Differences;
28
29 use SQL::Translator;
30 use SQL::Translator::Producer::TTSchema;
31
32 # Parse the test XML schema
33 my $obj;
34 $obj = SQL::Translator->new(
35     debug          => DEBUG, #$opt{d},
36     show_warnings  => 1,
37     add_drop_table => 1,
38     from           => "XML-SQLFairy",
39     filename       => "$Bin/data/xml/schema.xml",
40     to             => "Producer::BaseTest::produce",
41 );
42 my $out;
43 lives_ok { $out = $obj->translate; }  "Translate ran";
44 is $obj->error, ''                   ,"No errors";
45 ok $out ne ""                        ,"Produced something!";
46 local $/ = undef; # slurp
47 eq_or_diff $out, <DATA>              ,"Output looks right";
48
49 print $out if DEBUG;
50 #print "Debug:", Dumper($obj) if DEBUG;
51
52 __DATA__
53 Hello World
54 Tables: Basic
55
56 Basic
57 ------
58 Fields: id title description email explicitnulldef explicitemptystring emptytagdef