Commit | Line | Data |
---|---|---|
5a2e0210 | 1 | use strict; |
2 | use warnings; | |
f0e3c221 | 3 | |
5a2e0210 | 4 | use Test::More; |
67a1cd50 | 5 | use Config::Any; |
f0e3c221 | 6 | use Config::Any::JSON; |
7 | ||
5a2e0210 | 8 | if ( !Config::Any::JSON->is_supported ) { |
9 | plan skip_all => 'JSON format not supported'; | |
10 | } | |
11 | else { | |
67a1cd50 | 12 | plan tests => 6; |
5a2e0210 | 13 | } |
f0e3c221 | 14 | |
5a2e0210 | 15 | { |
16 | my $config = Config::Any::JSON->load( 't/conf/conf.json' ); | |
f0e3c221 | 17 | ok( $config ); |
18 | is( $config->{ name }, 'TestApp' ); | |
19 | } | |
5770ffc0 | 20 | |
21 | # test invalid config | |
22 | { | |
77f14cda | 23 | my $file = 't/invalid/conf.json'; |
5770ffc0 | 24 | my $config = eval { Config::Any::JSON->load( $file ) }; |
25 | ||
26 | ok( !$config, 'config load failed' ); | |
dcfb1d1d | 27 | ok( $@, "error thrown ($@)" ); |
5770ffc0 | 28 | } |
67a1cd50 | 29 | |
30 | # parse error generated on invalid config | |
31 | { | |
32 | my $file = 't/invalid/conf.json'; | |
33 | my $config = eval { Config::Any->load_files( { files => [$file], use_ext => 1} ) }; | |
34 | ||
35 | ok( !$config, 'config load failed' ); | |
36 | ok( $@, "error thrown ($@)" ); | |
37 | } |