555e74e3fc1eb4e2ff27a0c5cd50439200ba5cf4
[p5sagit/Config-Any.git] / t / 52-json.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Config::Any;
6 use Config::Any::JSON;
7
8 if ( !Config::Any::JSON->is_supported ) {
9     plan skip_all => 'JSON format not supported';
10 }
11 else {
12     plan tests => 6;
13 }
14
15 {
16     my $config = Config::Any::JSON->load( 't/conf/conf.json' );
17     ok( $config );
18     is( $config->{ name }, 'TestApp' );
19 }
20
21 # test invalid config
22 {
23     my $file = 't/invalid/conf.json';
24     my $config = eval { Config::Any::JSON->load( $file ) };
25
26     ok( !$config, 'config load failed' );
27     ok( $@,       "error thrown ($@)" );
28 }
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 }