From: Joel Bernstein Date: Tue, 22 Aug 2006 21:18:27 +0000 (+0000) Subject: added some branch exercising tests in 10-branches.t and 51-ini.t, and a second INI... X-Git-Tag: v0.04~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=commitdiff_plain;h=8587679b9219b55bb8189772981387b0cd70b685 added some branch exercising tests in 10-branches.t and 51-ini.t, and a second INI-file test config --- diff --git a/t/10-branches.t b/t/10-branches.t new file mode 100644 index 0000000..3e0f400 --- /dev/null +++ b/t/10-branches.t @@ -0,0 +1,27 @@ +use Test::More tests => 9; +use Test::Exception; +use Config::Any; + +ok ( ! Config::Any->load_files(), "load_files expects args" ); +ok ( ! Config::Any->load_stems(), "load_stems expects args" ); + +{ + my @warnings; + local $SIG{__WARN__} = sub { push @warnings, @_ }; + Config::Any->load_files({}); + like (shift @warnings, qr/^no files specified/, "load_files expects files"); + Config::Any->load_stems({}); + like (shift @warnings, qr/^no stems specified/, "load_stems expects stems"); +} + +my @files = glob("t/conf/conf.*"); +my $filter = sub { return }; +ok(Config::Any->load_files({files=>\@files, use_ext=>0}), "use_ext 0 works"); +ok(Config::Any->load_files({files=>\@files, use_ext=>1}), "use_ext 1 works"); + +ok(Config::Any->load_files({files=>\@files, use_ext=>1, filter=>\&$filter}), "filter works"); +eval {Config::Any->load_files({files=>\@files, use_ext=>1, filter=>sub{die}}) }; +ok($@, "filter breaks"); + +my @stems = qw(t/conf/conf); +ok(Config::Any->load_stems({stems=>\@stems, use_ext=>1}), "load_stems with stems works"); diff --git a/t/51-ini.t b/t/51-ini.t index 206d1a7..17b5bcd 100644 --- a/t/51-ini.t +++ b/t/51-ini.t @@ -1,11 +1,17 @@ -use Test::More tests => 2; +use Test::More tests => 6; use Config::Any::INI; -my $config = eval { Config::Any::INI->load( 't/conf/conf.ini' ) }; +my $config = eval { Config::Any::INI->load( 't/conf/conf.ini' ) }; +my $simpleconfig = eval { Config::Any::INI->load( 't/conf/conf2.ini' ) }; SKIP: { - skip "Couldn't Load INI plugin", 2 if $@; + skip "Couldn't Load INI plugin", 6 if $@; ok( $config ); is( $config->{ name }, 'TestApp' ); + is( $config->{Component}->{Controller::Foo}->{foo}, 'bar'); + + ok( $simpleconfig ); + is( $simpleconfig->{ name }, 'TestApp' ); + is( $simpleconfig->{Controller::Foo}->{foo}, 'bar' ); } diff --git a/t/conf/conf2.ini b/t/conf/conf2.ini new file mode 100644 index 0000000..366619e --- /dev/null +++ b/t/conf/conf2.ini @@ -0,0 +1,7 @@ +name=TestApp + +[Controller::Foo] +foo=bar + +[Model::Baz] +qux=xyzzy