Commit | Line | Data |
952b2663 |
1 | #!/usr/bin/perl -w |
f5f03b78 |
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 | |
f5f03b78 |
12 | BEGIN { |
13 | maybe_plan(4, 'Template', 'Test::Differences') |
14 | } |
15 | use Test::Differences; |
16 | |
17 | use SQL::Translator; |
952b2663 |
18 | use FindBin qw/$Bin/; |
19 | # Access to test libs. We want Producer/BaseTest.pm from here. |
20 | use lib ("$Bin/lib"); |
21 | |
f5f03b78 |
22 | |
23 | # Parse the test XML schema |
24 | my $obj; |
25 | $obj = SQL::Translator->new( |
952b2663 |
26 | debug => 0, |
f5f03b78 |
27 | show_warnings => 1, |
28 | add_drop_table => 1, |
29 | from => "XML-SQLFairy", |
7266dab2 |
30 | filename => "$Bin/data/xml/schema.xml", |
f5f03b78 |
31 | to => "Producer::BaseTest::produce", |
f5f03b78 |
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 | |
f5f03b78 |
40 | |
41 | __DATA__ |
42 | Hello World |
53ec8b7d |
43 | Tables: Basic |
44 | |
f5f03b78 |
45 | Basic |
53ec8b7d |
46 | ------ |
47 | Fields: id title description email explicitnulldef explicitemptystring emptytagdef |