X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=t%2F52-json.t;h=555e74e3fc1eb4e2ff27a0c5cd50439200ba5cf4;hp=f4e45c3e947b4a70b6eff37127f254f031979920;hb=1afb249c67eda203b13fef661fd046bff0ee26cc;hpb=572501abb2165014af8973bf9a4aa1f8a522356d diff --git a/t/52-json.t b/t/52-json.t index f4e45c3..555e74e 100644 --- a/t/52-json.t +++ b/t/52-json.t @@ -1,11 +1,37 @@ -use Test::More tests => 2; - -use Config::Any::JSON; - -my $config = eval { Config::Any::JSON->load( 't/conf/conf.json' ) }; - -SKIP: { - skip "Couldn't Load JSON plugin", 2 if $@; - ok( $config ); - is( $config->{ name }, 'TestApp' ); -} +use strict; +use warnings; + +use Test::More; +use Config::Any; +use Config::Any::JSON; + +if ( !Config::Any::JSON->is_supported ) { + plan skip_all => 'JSON format not supported'; +} +else { + plan tests => 6; +} + +{ + my $config = Config::Any::JSON->load( 't/conf/conf.json' ); + ok( $config ); + is( $config->{ name }, 'TestApp' ); +} + +# test invalid config +{ + my $file = 't/invalid/conf.json'; + my $config = eval { Config::Any::JSON->load( $file ) }; + + ok( !$config, 'config load failed' ); + ok( $@, "error thrown ($@)" ); +} + +# parse error generated on invalid config +{ + my $file = 't/invalid/conf.json'; + my $config = eval { Config::Any->load_files( { files => [$file], use_ext => 1} ) }; + + ok( !$config, 'config load failed' ); + ok( $@, "error thrown ($@)" ); +}