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 | |
c2a19f63 |
8 | if ( !Config::Any::JSON->is_supported && !$ENV{RELEASE_TESTING} ) { |
5a2e0210 |
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 | |
e0186698 |
26 | is $config, undef, 'config load failed'; |
27 | isnt $@, '', '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 | |
e0186698 |
35 | is $config, undef, 'config load failed'; |
36 | isnt $@, '', 'error thrown'; |
67a1cd50 |
37 | } |