7170260e927aeb90fbf14ab77c19fe7e488d1769
[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', 'Test::Differences')
14 }
15 use Test::Differences;
16
17 use SQL::Translator;
18 use FindBin qw/$Bin/;
19 # Access to test libs. We want Producer/BaseTest.pm from here.
20 use lib ("$Bin/lib");
21
22
23 # Parse the test XML schema
24 my $obj;
25 $obj = SQL::Translator->new(
26     debug          => 0,
27     show_warnings  => 1,
28     add_drop_table => 1,
29     from           => "XML-SQLFairy",
30     filename       => "$Bin/data/xml/schema.xml",
31     to             => "Producer::BaseTest::produce",
32 );
33 my $out;
34 lives_ok { $out = $obj->translate; }  "Translate ran";
35 is $obj->error, ''                   ,"No errors";
36 ok $out ne ""                        ,"Produced something!";
37 local $/ = undef; # slurp
38 eq_or_diff $out, <DATA>              ,"Output looks right";
39
40
41 __DATA__
42 Hello World
43 Tables: Basic
44
45 Basic
46 ------
47 Fields: id title description email explicitnulldef explicitemptystring emptytagdef