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