Skip to content

Commit 49f0f31

Browse files
committed
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.
1 parent 4384692 commit 49f0f31

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Changes for SQL::Translator
2323
* Fix missing semicolons between PostGIS statements
2424
* Fix string and identifier quoting in PostGIS statements
2525
* Fix intermittent test failures (RT#108460)
26+
* Fix relying on exact serialisation for JSON/YAML tests (RT#121901)
2627

2728
0.11021 2015-01-29
2829

t/23json.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use warnings;
22
use strict;
33
use Test::More;
4-
use Test::Differences;
4+
use Test::Exception;
55
use Test::SQL::Translator qw(maybe_plan);
66
use SQL::Translator;
77
use FindBin '$Bin';
@@ -16,7 +16,7 @@ BEGIN {
1616

1717
my $sqlt_version = $SQL::Translator::VERSION;
1818
use JSON;
19-
my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
19+
my $json = from_json(<<JSON);
2020
{
2121
"schema" : {
2222
"procedures" : {},
@@ -306,5 +306,5 @@ my $tr = SQL::Translator->new(
306306
);
307307

308308
my $out;
309-
ok( $out = $tr->translate, 'Translate SQLite to JSON' );
310-
eq_or_diff( $out, $json, 'JSON matches expected' );
309+
lives_ok { $out = from_json($tr->translate) } 'Translate SQLite to JSON';
310+
is_deeply( $out, $json, 'JSON matches expected' );

t/24yaml.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use warnings;
22
use strict;
33
use Test::More;
4-
use Test::Differences;
4+
use Test::Exception;
55
use Test::SQL::Translator qw(maybe_plan);
66
use SQL::Translator;
77
use FindBin '$Bin';
@@ -13,8 +13,8 @@ BEGIN {
1313
}
1414

1515
my $sqlt_version = $SQL::Translator::VERSION;
16-
use YAML qw(Dump Load);
17-
my $yaml = Dump(Load(<<YAML));
16+
use YAML qw(Load);
17+
my $yaml = Load(<<YAML);
1818
---
1919
schema:
2020
procedures: {}
@@ -247,5 +247,5 @@ my $tr = SQL::Translator->new(
247247
);
248248

249249
my $out;
250-
ok( $out = $tr->translate, 'Translate SQLite to YAML' );
251-
eq_or_diff( $out, $yaml, 'YAML matches expected' );
250+
lives_ok { $out = Load($tr->translate) } 'Translate SQLite to YAML';
251+
is_deeply( $out, $yaml, 'YAML matches expected' );

0 commit comments

Comments
 (0)