-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from duckduckgo/jbarrett/json-sanity-check
Metadata sanity checks
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
requires 'Cpanel::JSON::XS'; | ||
requires 'Locale::PO'; | ||
requires 'Test::Fatal'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
use File::Basename; | ||
use Cpanel::JSON::XS qw/ decode_json /; | ||
use Scalar::Util qw/ reftype /; | ||
use Test::Fatal qw/ lives_ok /; | ||
|
||
chdir dirname(__FILE__) . "/.."; | ||
|
||
my $locales; | ||
my $file = 'locales.json'; | ||
|
||
lives_ok { | ||
$locales = decode_json( do { | ||
local $/ = undef; | ||
open my $fh, '<', $file or die "could not open $file: $!"; | ||
<$fh>; | ||
} ) | ||
} 'locales.json parsed OK'; | ||
|
||
is( reftype $locales, 'HASH', 'locales data appears to exist' ); | ||
my @locale_codes = keys %{ $locales }; | ||
ok( @locale_codes > 0, 'locales data appears to be populated' ); | ||
|
||
for my $locale_code ( @locale_codes ) { | ||
for my $key ( qw/ locale name_in_english name_in_local rtl / ) { | ||
ok( defined( $locales->{ $locale_code }->{ $key } ), | ||
"$key defined for $locale_code" ); | ||
} | ||
} | ||
|
||
done_testing; |
File renamed without changes.