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 { |
3e1ed76b |
13 | maybe_plan(4, 'Template 2.20', |
14 | 'Test::Differences', |
8c4efd11 |
15 | 'SQL::Translator::Parser::XML::SQLFairy') |
f5f03b78 |
16 | } |
17 | use Test::Differences; |
18 | |
19 | use SQL::Translator; |
952b2663 |
20 | use FindBin qw/$Bin/; |
21 | # Access to test libs. We want Producer/BaseTest.pm from here. |
22 | use lib ("$Bin/lib"); |
23 | |
f5f03b78 |
24 | |
25 | # Parse the test XML schema |
26 | my $obj; |
27 | $obj = SQL::Translator->new( |
952b2663 |
28 | debug => 0, |
9768b204 |
29 | show_warnings => 0, |
f5f03b78 |
30 | add_drop_table => 1, |
31 | from => "XML-SQLFairy", |
7266dab2 |
32 | filename => "$Bin/data/xml/schema.xml", |
f5f03b78 |
33 | to => "Producer::BaseTest::produce", |
f5f03b78 |
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 | |
f5f03b78 |
42 | |
43 | __DATA__ |
44 | Hello World |
b08b5416 |
45 | Tables: Basic, Another |
53ec8b7d |
46 | |
f5f03b78 |
47 | Basic |
53ec8b7d |
48 | ------ |
b08b5416 |
49 | Fields: id title description email explicitnulldef explicitemptystring emptytagdef another_id timest |
50 | |
51 | Another |
52 | ------ |
e3472b3b |
53 | Fields: id num |
b08b5416 |
54 | |