X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F17sqlfxml-producer.t;h=7989e35d43ea2aa0139cba66ef9cb41a249f062c;hb=8d59dd515dae2a6d6dd50da7aa7eb2367042e8e8;hp=050bc42fa0fc856f935955a13f041cf783076e04;hpb=d37416fd148d986a4c228899e74b80404806bb23;p=dbsrgits%2FSQL-Translator.git diff --git a/t/17sqlfxml-producer.t b/t/17sqlfxml-producer.t index 050bc42..7989e35 100644 --- a/t/17sqlfxml-producer.t +++ b/t/17sqlfxml-producer.t @@ -40,6 +40,17 @@ use Test::Differences; use SQL::Translator; use SQL::Translator::Producer::XML::SQLFairy; +# Due to formatters being able to change style, e.g. by entries in .rc files +# in $HOME, the layout and or indent might differ slightly. As leading white +# is not important in XML, strip it when comparing +sub xml_equals +{ + my ($got, $expect, $msg) = (@_, "XML looks right"); + $got =~ s/^ +//gm; + $expect =~ s/^ +//gm; + eq_or_diff $got, $expect, $msg; +} + # # basic stuff # @@ -105,7 +116,7 @@ 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"; +xml_equals $xml, $ans; } # end basic stuff @@ -157,8 +168,8 @@ EOXML ok("$xml" ne "" ,"Produced something!"); print "XML attrib_values=>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"; + $xml =~ s/^([^\n]*\n){7}//m; + xml_equals $xml, $ans; } # end View # @@ -182,7 +193,7 @@ $ans = < - + update modified=timestamp(); @@ -211,6 +222,7 @@ EOXML database_events => [$database_event], table => $table, action => $action, + scope => 'row', extra => { hello => "world" }, ) or die $s->error; @@ -220,8 +232,8 @@ EOXML ok("$xml" ne "" ,"Produced something!"); print "XML attrib_values=>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"; + $xml =~ s/^([^\n]*\n){7}//m; + xml_equals $xml, $ans; } # end Trigger # @@ -276,8 +288,8 @@ EOXML ok("$xml" ne "" ,"Produced something!"); print "XML attrib_values=>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"; + $xml =~ s/^([^\n]*\n){7}//m; + xml_equals $xml, $ans; } # end Procedure # @@ -297,6 +309,14 @@ $ans = < + + + + + + + + @@ -326,6 +346,18 @@ EOXML ) or die $t->error; $f->extra(ZEROFILL => "1"); + $t->add_field( + name => "bar", + data_type => "numeric", + size => "10,2", + ) or die $t->error; + $t->add_field( + name => "baz", + data_type => "decimal", + size => [8,3], + ) or die $t->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 (Field.extra) ran"; @@ -333,5 +365,5 @@ EOXML 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_equals $xml, $ans; } # end extra