aboutsummaryrefslogtreecommitdiffstats
path: root/t/config.t
blob: 4ecb8a791203dcbda290ed4b177aa6e281ca847e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use Test::More;
use Iurt::Config;

my %config_usage = (
    option_with_false_default => {
	default => 0
    },
    option_with_true_default => {
	default => 1
    },
);
my $config = {
    option_with_false_default => 1,
    option_with_true_default => 0,
};
my %run;

config_init(\%config_usage, $config, \%run);
is($config->{option_with_false_default}, 1, 'false default and true in config file');
is($config->{option_with_true_default}, 0, 'true default and false in config file');

$config = {};
$run{config}{option_with_false_default} = 1;
$run{config}{option_with_true_default} = 0;

config_init(\%config_usage, $config, \%run);
is($config->{option_with_false_default}, 1, 'false default and true on cmdline');
is($config->{option_with_true_default}, 0, 'true default and false on cmdline');

$config = {
    option_with_false_default => 1,
    option_with_true_default => 0,
};
$run{config}{option_with_false_default} = 0;
$run{config}{option_with_true_default} = 1;
config_init(\%config_usage, $config, \%run);
is($config->{option_with_false_default}, 0, 'false default, true in config file, false on cmdline');
is($config->{option_with_true_default}, 1, 'true default, false in config file, true on cmdline');

done_testing();