#! /usr/bin/env perl # -*- perl -*-
BEGIN {
my
$test_dir
= __FILE__;
$test_dir
=~ s/[-a-z0-9]+\.t$//i;
unshift
@INC
,
$test_dir
;
}
my
(
$site
,
$got
,
$expected
);
my
$expected
= {
plugins
=>
'_plug-ins'
,
po
=>
'_po'
,
timestamp
=>
'_timestamp'
,
views
=>
'_views'
};
$site
= TestSite->new(
name
=>
'config-defaults'
,
config
=> {
paths
=> {
plugins
=>
'_plug-ins'
}
}
);
$got
= Qgoda->new->config->{paths};
delete
$got
->{site};
is_deeply
$got
,
$expected
,
'replace simple key in top-level object'
;
my
$schema
= Qgoda::Schema->config->{properties}->{processors}->{properties};
$expected
= {
chains
=> dclone(
$schema
->{chains}->{
default
}),
options
=> dclone(
$schema
->{options}->{
default
}),
triggers
=> dclone(
$schema
->{triggers}->{
default
}),
};
$expected
->{options}->{HTMLFilter}->{TOC}->{start} = 3;
$site
= TestSite->new(
name
=>
'config-defaults'
,
config
=> {
processors
=> {
options
=> {
HTMLFilter
=> {
TOC
=> {
start
=> 3
}
}
}
}
}
);
$got
= Qgoda->new->config->{processors};
is_deeply
$got
,
$expected
,
'individually overwrite deeply nested processor option'
;
$site
= TestSite->new(
name
=>
'config-defaults'
,
config
=> {
helpers
=> {
make
=>
'make'
,
yarn
=> [
qw(yarn start)
]
},
po
=> {
msgfmt
=>
'msgfmt'
,
msgmerge
=>
'msgmerge'
,
qgoda
=>
'qgoda'
,
tt2
=>
'_my_views'
,
xgettext
=>
'xgettext'
,
'xgettext-tt2'
=>
'xgettext-tt2'
},
defaults
=> [
{
files
=>
'/fi'
,
values
=> {
lingua
=>
'fi'
}
}
],
exclude
=>
'*.bak'
,
'exclude-watch'
=>
'*.bak'
,
}
);
$got
= Qgoda->new->rawConfig;
is_deeply
$got
->{helpers}->{make}, [
'make'
];
is_deeply
$got
->{helpers}->{yarn}, [
'yarn'
,
'start'
];
is_deeply
$got
->{po}->{msgfmt}, [
'msgfmt'
];
ok
$got
->{defaults}->[0];
ok
ref
$got
->{defaults}->[0];
ok
ref
$got
->{defaults}->[0]->{files};
is ((reftype
$got
->{defaults}->[0]->{files}),
'ARRAY'
);
is
'/fi'
,
$got
->{defaults}->[0]->{files}->[0];
ok
$got
->{exclude};
ok
ref
$got
->{exclude};
is ((reftype
$got
->{exclude}),
'ARRAY'
);
is
$got
->{exclude}->[0],
'*.bak'
;
ok
$got
->{
'exclude-watch'
};
ok
ref
$got
->{
'exclude-watch'
};
is ((reftype
$got
->{
'exclude-watch'
}),
'ARRAY'
);
is
$got
->{
'exclude-watch'
}->[0],
'*.bak'
;
ok
ref
$got
->{po}->{tt2};
is ((reftype
$got
->{po}->{tt2}),
'ARRAY'
);
is
$got
->{po}->{tt2}->[0],
'_my_views'
;
$site
= TestSite->new(
name
=>
'config-defaults'
,
config
=> {
paths
=> {
views
=>
'_your_views'
}
}
);
$got
= Qgoda->new->rawConfig;
is ((reftype
$got
->{po}->{tt2}),
'ARRAY'
);
ok
ref
$got
->{po}->{tt2};
is ((reftype
$got
->{po}->{tt2}),
'ARRAY'
);
is
$got
->{po}->{tt2}->[0],
'_your_views'
;
$site
->tearDown;
done_testing;