1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use strict; |
use strict; |
4 |
use Test::More tests => 8; |
use Test::More tests => 24; |
5 |
use Test::Exception; |
use Test::Exception; |
6 |
use blib; |
use blib; |
7 |
|
|
19 |
|
|
20 |
my $path = "$abs_path/conf/test.yml"; |
my $path = "$abs_path/conf/test.yml"; |
21 |
|
|
22 |
ok(my $c = new WebPAC::Config( path => $path ), "new"); |
ok(my $config = new WebPAC::Config( path => $path ), "new"); |
23 |
|
|
24 |
cmp_ok($c->{path}, 'eq', $path, "path $path"); |
cmp_ok($config->{path}, 'eq', $path, "path $path"); |
25 |
|
|
26 |
ok($c->{config}, "config exist"); |
ok($config->{config}, "config exist"); |
27 |
|
|
28 |
isa_ok($c->databases, 'HASH', "databases"); |
# $config->databases |
|
|
|
|
my @names = $c->databases; |
|
29 |
|
|
30 |
|
isa_ok($config->databases, 'HASH', "databases"); |
31 |
|
my @names = $config->databases; |
32 |
isa_ok(\@names, 'ARRAY', "databases names"); |
isa_ok(\@names, 'ARRAY', "databases names"); |
|
|
|
33 |
cmp_ok(@names, '==', 3, "got 3 names"); |
cmp_ok(@names, '==', 3, "got 3 names"); |
34 |
|
isa_ok($config->databases, 'HASH', "databases"); |
35 |
|
|
36 |
|
diag '$config->webpac = ', dump($config->webpac) if ($debug); |
37 |
|
|
38 |
|
isa_ok($config->webpac, 'HASH', "webpac"); |
39 |
|
my @inputs = $config->webpac('inputs'); |
40 |
|
diag "inputs = ",dump( @inputs ) if ($debug); |
41 |
|
isa_ok(\@inputs, 'ARRAY', "inputs"); |
42 |
|
cmp_ok(@inputs, '==', 2, "got 2 webpac inputs"); |
43 |
|
|
44 |
|
$config->iterate_inputs(sub { |
45 |
|
my ($input,$database,$db_config) = @_; |
46 |
|
isa_ok($input, 'HASH', 'input'); |
47 |
|
ok($database, 'database'); |
48 |
|
isa_ok($db_config, 'HASH', 'database config'); |
49 |
|
}); |