Skip to content

Commit

Permalink
Merge pull request #81 from duckduckgo/jbarrett/json-sanity-check
Browse files Browse the repository at this point in the history
Metadata sanity checks
  • Loading branch information
andrey-p authored Mar 18, 2019
2 parents e108f11 + ca6663f commit 35811e8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
requires 'Cpanel::JSON::XS';
requires 'Locale::PO';
requires 'Test::Fatal';
34 changes: 34 additions & 0 deletions t/01-meta.t
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.

0 comments on commit 35811e8

Please sign in to comment.