add travis config
[p5sagit/Config-Any.git] / t / 50-general.t
CommitLineData
5a2e0210 1use strict;
2use warnings;
f0e3c221 3
5a2e0210 4use Test::More;
67a1cd50 5use Config::Any;
f0e3c221 6use Config::Any::General;
7
c2a19f63 8if ( !Config::Any::General->is_supported && !$ENV{RELEASE_TESTING}) {
5a2e0210 9 plan skip_all => 'Config::General format not supported';
10}
11else {
67a1cd50 12 plan tests => 9;
5a2e0210 13}
f0e3c221 14
5a2e0210 15{
16 my $config = Config::Any::General->load( 't/conf/conf.conf' );
f0e3c221 17 ok( $config );
18 is( $config->{ name }, 'TestApp' );
9ac432c2 19 ok( exists $config->{ Component } );
5a2e0210 20}
9ac432c2 21
5a2e0210 22{
23 my $config = Config::Any::General->load( 't/conf/conf.conf',
24 { -LowerCaseNames => 1 } );
9ac432c2 25 ok( exists $config->{ component } );
f0e3c221 26}
5770ffc0 27
7adf5673 28{
766100bd 29 my $config
30 = Config::Any::General->load( 't/conf/single_element_arrayref.conf' );
31 is_deeply $config->{ foo }, [ 'bar' ], 'single element arrayref';
7adf5673 32}
33
5770ffc0 34# test invalid config
35{
77f14cda 36 my $file = 't/invalid/conf.conf';
5770ffc0 37 my $config = eval { Config::Any::General->load( $file ) };
38
e0186698 39 is $config, undef, 'config load failed';
40 isnt $@, '', 'error thrown';
5770ffc0 41}
67a1cd50 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
e0186698 48 is $config, undef, 'config load failed';
49 isnt $@, '', 'error thrown';
67a1cd50 50}