Release commit for 1.62
[dbsrgits/SQL-Translator.git] / t / 62roundtrip_datacheck.t
CommitLineData
dc34f950 1use warnings;
2use strict;
3use Test::SQL::Translator;
4use Test::Differences;
5use FindBin qw/$Bin/;
6
7BEGIN {
8 maybe_plan(1, 'SQL::Translator::Parser::XML',
9 'SQL::Translator::Producer::XML');
10}
11
12# It's very hard to read and modify YAML by hand. Thus we
13# use an XML file for definitions, and generate a YAML from
14# it in Makefile.PL, so we do not saddle the user with XML
15# dependencies for testing. This test makes sure they do
16# not drift apart.
17
18use SQL::Translator;
19
20my $base_xml_fn = "$Bin/data/roundtrip.xml";
21my $autogen_yaml_fn = "$Bin/data/roundtrip_autogen.yaml";
22
23my $orig_xml = _parse_to_xml ($base_xml_fn, 'XML');
24my $new_xml = _parse_to_xml ($autogen_yaml_fn, 'YAML');
25
26eq_or_diff ("$new_xml", "$orig_xml", 'YAML test schema matches original XML schema');
27
28sub _parse_to_xml {
29 my ($fn, $type) = @_;
30
31 my $tr = SQL::Translator->new;
32 $tr->no_comments (1); # this will drop the XML header
33
34 my $xml = $tr->translate (
35 parser => $type,
36 file => $fn,
37 producer => 'XML',
38 ) or die $tr->error;
39
40 return $xml;
41}