X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F17sqlfxml-producer.t;h=0f032e789cf46684fa390e6354cec8396a24a4d3;hb=ec791002ba1fed6772d86a89de64ff65c1be3545;hp=54ccf8a515110ad1dc29e5a387dff21fa896964a;hpb=8571d1980c9ac71cf8f530cbaba1280c2d90b296;p=dbsrgits%2FSQL-Translator.git diff --git a/t/17sqlfxml-producer.t b/t/17sqlfxml-producer.t index 54ccf8a..0f032e7 100644 --- a/t/17sqlfxml-producer.t +++ b/t/17sqlfxml-producer.t @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl -w # vim:filetype=perl # Before `make install' is performed this script should be runnable with @@ -30,7 +30,7 @@ local $SIG{__WARN__} = sub { #============================================================================= BEGIN { - maybe_plan(18, + maybe_plan(12, 'XML::Writer', 'Test::Differences', 'SQL::Translator::Producer::XML::SQLFairy'); @@ -41,268 +41,37 @@ use SQL::Translator; use SQL::Translator::Producer::XML::SQLFairy; # -# emit_empty_tags => 0 +# basic stuff # { my ($obj,$ans,$xml); $ans = < - - - - Basic - 1 - - - id - integer - 10 - 0 - 1 - 1 - 0 - comment on id field - 1 - - - title - varchar - 100 - 0 - hello - 0 - 0 - 0 - - 2 - - - description - text - 65535 - 1 - - 0 - 0 - 0 - - 3 - - - email - varchar - 255 - 1 - 0 - 0 - 0 - - 4 - - - - - titleindex - NORMAL - title - - - - - - - PRIMARY KEY - id - - - - - - - - 1 - - - - UNIQUE - email - - - - - - - - 1 - - - - -EOXML - -$obj = SQL::Translator->new( - debug => DEBUG, - trace => TRACE, - show_warnings => 1, - add_drop_table => 1, - from => 'MySQL', - to => 'XML-SQLFairy', -); -lives_ok {$xml = $obj->translate($file);} "Translate (emit_empty_tags=>0) ran"; -ok("$xml" ne "" ,"Produced something!"); -print "XML:\n$xml" if DEBUG; -# Strip sqlf header with its variable date so we diff safely -$xml =~ s/^([^\n]*\n){7}//m; -eq_or_diff $xml, $ans ,"XML looks right"; - -} # end emit_empty_tags=>0 - -# -# emit_empty_tags => 1 -# -{ -my ($obj,$ans,$xml); - -$ans = < - - - - Basic - 2 - - - id - integer - 10 - 0 - - 1 - 1 - 0 - comment on id field - 5 - - - title - varchar - 100 - 0 - hello - 0 - 0 - 0 - - 6 - - - description - text - 65535 - 1 - - 0 - 0 - 0 - - 7 - - - email - varchar - 255 - 1 - - 0 - 0 - 0 - - 8 - - - - - titleindex - NORMAL - title - - - - - - - PRIMARY KEY - id - - - - - - - - 1 - - - - UNIQUE - email - - - - - - - - 1 - - - - -EOXML - -$obj = SQL::Translator->new( - debug => DEBUG, - trace => TRACE, - show_warnings => 1, - add_drop_table => 1, - from => 'MySQL', - to => 'XML-SQLFairy', - producer_args => { emit_empty_tags => 1 }, -); -lives_ok { $xml=$obj->translate($file); } "Translate (emit_empty_tags=>1) ran"; -ok("$xml" ne "" ,"Produced something!"); -print "XML emit_empty_tags=>1:\n$xml" if DEBUG; -# Strip sqlf header with its variable date so we diff safely -$xml =~ s/^([^\n]*\n){7}//m; -eq_or_diff $xml, $ans ,"XML looks right"; - -} # end emit_empty_tags => 1 - -# -# attrib_values => 1 -# -{ -my ($obj,$ans,$xml); - -$ans = < - - - - - - - - - - - - - - - - + + + + + comment on id field + + + + + + + + + + + + + + + + + + + + EOXML $obj = SQL::Translator->new( @@ -312,16 +81,15 @@ $obj = SQL::Translator->new( add_drop_table => 1, from => "MySQL", to => "XML-SQLFairy", - producer_args => { attrib_values => 1 }, ); lives_ok {$xml = $obj->translate($file);} "Translate (attrib_values=>1) ran"; ok("$xml" ne "" ,"Produced something!"); -print "XML attrib_values=>1:\n$xml" if DEBUG; +print "XML:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely -$xml =~ s/^([^\n]*\n){7}//m; -eq_or_diff $xml, $ans ,"XML looks right"; +$xml =~ s/^([^\n]*\n){7}//m; +eq_or_diff $xml, $ans, "XML looks right"; -} # end attrib_values => 1 +} # end basic stuff # # View @@ -331,16 +99,11 @@ eq_or_diff $xml, $ans ,"XML looks right"; my ($obj,$ans,$xml); $ans = < - - - - foo_view - select name, age from person - name,age - 1 - - + + + select name, age from person + + EOXML $obj = SQL::Translator->new( @@ -361,7 +124,7 @@ EOXML fields => $fields, schema => $s, ) or die $s->error; - + # As we have created a Schema we give translate a dummy string so that # it will run the produce. lives_ok {$xml =$obj->translate("FOO");} "Translate (View) ran"; @@ -380,18 +143,11 @@ EOXML my ($obj,$ans,$xml); $ans = < - - - - foo_trigger - insert - update modified=timestamp(); - foo - after - 1 - - + + + update modified=timestamp(); + + EOXML $obj = SQL::Translator->new( @@ -415,7 +171,7 @@ EOXML on_table => $on_table, action => $action, ) or die $s->error; - + # As we have created a Schema we give translate a dummy string so that # it will run the produce. lives_ok {$xml =$obj->translate("FOO");} "Translate (Trigger) ran"; @@ -434,18 +190,12 @@ EOXML my ($obj,$ans,$xml); $ans = < - - - - foo_proc - select foo from bar - foo,bar - Nomar - Go Sox! - 1 - - + + + select foo from bar + Go Sox! + + EOXML $obj = SQL::Translator->new(