X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2F1-config.t;h=914bcb5ef88298705482c55b17fe9b50acb4ab57;hb=HEAD;hp=73850220f016226f02c51274d7f5f4d7b8fd84ff;hpb=449fc14e93251890982aa5c8109f549e107cd530;p=webpac2 diff --git a/t/1-config.t b/t/1-config.t index 7385022..914bcb5 100755 --- a/t/1-config.t +++ b/t/1-config.t @@ -1,34 +1,43 @@ #!/usr/bin/perl -w use strict; -use Test::More tests => 8; -use Test::Exception; -use blib; +use lib 'lib'; -use Data::Dump qw/dump/; -use Cwd qw/abs_path/; +use Test::More tests => 28; BEGIN { +use_ok( 'WebPAC::Test' ); use_ok( 'WebPAC::Config' ); } -my $debug = shift @ARGV; - -ok(my $abs_path = abs_path($0), "abs_path"); -$abs_path =~ s#/[^/]*$#/#; - my $path = "$abs_path/conf/test.yml"; -ok(my $c = new WebPAC::Config( path => $path ), "new"); +ok(my $config = new WebPAC::Config( path => $path ), "new"); -cmp_ok($c->{path}, 'eq', $path, "path $path"); +cmp_ok($config->{path}, 'eq', $path, "path $path"); -ok($c->{config}, "config exist"); +ok($config->{config}, "config exist"); -isa_ok($c->databases, 'HASH', "databases"); - -my @names = $c->databases; +# $config->databases +isa_ok($config->databases, 'HASH', "databases"); +my @names = $config->databases; isa_ok(\@names, 'ARRAY', "databases names"); - cmp_ok(@names, '==', 3, "got 3 names"); +isa_ok($config->databases, 'HASH', "databases"); + +diag '$config->webpac = ', dump($config->webpac) if ($debug); + +isa_ok($config->webpac, 'HASH', "webpac"); +my @inputs = $config->webpac('inputs'); +diag "inputs = ",dump( @inputs ) if ($debug); +isa_ok(\@inputs, 'ARRAY', "inputs"); +cmp_ok(@inputs, '==', 2, "got 2 webpac inputs"); + +$config->iterate_inputs(sub { + my ($input,$database,$db_config) = @_; + isa_ok($input, 'HASH', 'input'); + ok($database, 'database'); + isa_ok($db_config, 'HASH', 'database config'); + isa_ok($input->{normalize}, 'ARRAY', 'normalize'); +});