properly document JSON modules used
[p5sagit/Config-Any.git] / t / 50-general.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Config::Any;
6 use Config::Any::General;
7
8 if ( !Config::Any::General->is_supported && !$ENV{RELEASE_TESTING}) {
9     plan skip_all => 'Config::General format not supported';
10 }
11 else {
12     plan tests => 9;
13 }
14
15 {
16     my $config = Config::Any::General->load( 't/conf/conf.conf' );
17     ok( $config );
18     is( $config->{ name }, 'TestApp' );
19     ok( exists $config->{ Component } );
20 }
21
22 {
23     my $config = Config::Any::General->load( 't/conf/conf.conf',
24         { -LowerCaseNames => 1 } );
25     ok( exists $config->{ component } );
26 }
27
28 {
29     my $config
30         = Config::Any::General->load( 't/conf/single_element_arrayref.conf' );
31     is_deeply $config->{ foo }, [ 'bar' ], 'single element arrayref';
32 }
33
34 # test invalid config
35 {
36     my $file = 't/invalid/conf.conf';
37     my $config = eval { Config::Any::General->load( $file ) };
38
39     is $config, undef, 'config load failed';
40     isnt $@, '', 'error thrown';
41 }
42
43 # parse error generated on invalid config
44 {
45     my $file = 't/invalid/conf.conf';
46     my $config = eval { Config::Any->load_files( { files => [$file], use_ext => 1} ) };
47
48     is $config, undef, 'config load failed';
49     isnt $@, '', 'error thrown';
50 }