From: Dagfinn Ilmari Mannsåker Date: Wed, 6 Sep 2017 14:57:04 +0000 (+0100) Subject: Fix relying on exact serialisation for JSON/YAML tests (RT#121901) X-Git-Tag: v0.11022~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=49f0f316cadb67de79e4b361e38d0139cf3b5fc4;p=dbsrgits%2FSQL-Translator.git Fix relying on exact serialisation for JSON/YAML tests (RT#121901) Instead, decode the expected and generated JSON/YAML and use is_deeply() on the data structures. --- diff --git a/Changes b/Changes index d9e4ba4..a307d5e 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,7 @@ Changes for SQL::Translator * Fix missing semicolons between PostGIS statements * Fix string and identifier quoting in PostGIS statements * Fix intermittent test failures (RT#108460) + * Fix relying on exact serialisation for JSON/YAML tests (RT#121901) 0.11021 2015-01-29 diff --git a/t/23json.t b/t/23json.t index 0f96e47..7ed847e 100644 --- a/t/23json.t +++ b/t/23json.t @@ -1,7 +1,7 @@ use warnings; use strict; use Test::More; -use Test::Differences; +use Test::Exception; use Test::SQL::Translator qw(maybe_plan); use SQL::Translator; use FindBin '$Bin'; @@ -16,7 +16,7 @@ BEGIN { my $sqlt_version = $SQL::Translator::VERSION; use JSON; -my $json = to_json(from_json(< 1, pretty => 1 }); +my $json = from_json(<new( ); my $out; -ok( $out = $tr->translate, 'Translate SQLite to JSON' ); -eq_or_diff( $out, $json, 'JSON matches expected' ); +lives_ok { $out = from_json($tr->translate) } 'Translate SQLite to JSON'; +is_deeply( $out, $json, 'JSON matches expected' ); diff --git a/t/24yaml.t b/t/24yaml.t index 89d4cbb..8c6d1cf 100644 --- a/t/24yaml.t +++ b/t/24yaml.t @@ -1,7 +1,7 @@ use warnings; use strict; use Test::More; -use Test::Differences; +use Test::Exception; use Test::SQL::Translator qw(maybe_plan); use SQL::Translator; use FindBin '$Bin'; @@ -13,8 +13,8 @@ BEGIN { } my $sqlt_version = $SQL::Translator::VERSION; -use YAML qw(Dump Load); -my $yaml = Dump(Load(<new( ); my $out; -ok( $out = $tr->translate, 'Translate SQLite to YAML' ); -eq_or_diff( $out, $yaml, 'YAML matches expected' ); +lives_ok { $out = Load($tr->translate) } 'Translate SQLite to YAML'; +is_deeply( $out, $yaml, 'YAML matches expected' );