remove test. forgot to switch branches.
[p5sagit/Config-Any.git] / t / 51-ini.t
CommitLineData
5a2e0210 1use strict;
2use warnings;
41f47406 3
5a2e0210 4use Test::More;
41f47406 5use Config::Any::INI;
6
5a2e0210 7if ( !Config::Any::INI->is_supported ) {
8 plan skip_all => 'INI format not supported';
9}
10else {
5770ffc0 11 plan tests => 13;
5a2e0210 12}
41f47406 13
5a2e0210 14{
15 my $config = Config::Any::INI->load( 't/conf/conf.ini' );
16 ok( $config, 'config loaded' );
41f47406 17 is( $config->{ name }, 'TestApp', "toplevel key lookup succeeded" );
5a2e0210 18 is( $config->{ Component }->{ 'Controller::Foo' }->{ foo },
92a04e78 19 'bar', "nested hashref hack lookup succeeded" );
5a2e0210 20}
92a04e78 21
5a2e0210 22{
23 my $config = Config::Any::INI->load( 't/conf/conf2.ini' );
24 ok( $config, 'config loaded' );
25 is( $config->{ name }, 'TestApp', "toplevel key lookup succeeded" );
26 is( $config->{ 'Controller::Foo' }->{ foo },
92a04e78 27 'bar', "nested hashref hack lookup succeeded" );
41f47406 28}
29
5a2e0210 30{
31 local $Config::Any::INI::MAP_SECTION_SPACE_TO_NESTED_KEY = 0;
32 my $config = Config::Any::INI->load( 't/conf/conf.ini' );
33 ok( $config, 'config loaded (no-map-space mode)' );
34 is( $config->{ name }, 'TestApp', "toplevel key lookup succeeded" );
35 is( $config->{ 'Component Controller::Foo' }->{ foo },
92a04e78 36 'bar', "unnested key lookup succeeded" );
41f47406 37}
5a2e0210 38
39{
40 my $config = Config::Any::INI->load( 't/conf/subsections.ini' );
41
42 my %expected
43 = ( section1 =>
44 { a => 1, subsection1 => { b => 2 }, subsection2 => { c => 3 } }
45 );
46 ok( $config, 'config loaded' );
47 is_deeply( $config, \%expected, 'subsections parsed properly' );
48}
5770ffc0 49
50# test invalid config
51{
77f14cda 52 my $file = 't/invalid/conf.ini';
5770ffc0 53 my $config = eval { Config::Any::INI->load( $file ) };
54
55 ok( !$config, 'config load failed' );
dcfb1d1d 56 ok( $@, "error thrown ($@)" );
5770ffc0 57}