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
#
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
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
#
</tables>
<views></views>
<triggers>
- <trigger name="foo_trigger" database_events="insert" on_table="Basic" perform_action_when="after" order="1">
+ <trigger name="foo_trigger" database_events="insert" on_table="Basic" perform_action_when="after" order="1" scope="row">
<action>update modified=timestamp();</action>
<extra hello="world" />
</trigger>
database_events => [$database_event],
table => $table,
action => $action,
+ scope => 'row',
extra => { hello => "world" },
) or die $s->error;
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
#
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
#
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