aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2017-10-04 20:04:10 +0100
committerPascal Terjan <pterjan@mageia.org>2017-10-04 20:04:57 +0100
commit435e218e4dcc413e1d74f1ad39c7882de5b9b7ee (patch)
tree9947c81fe0a312b1ddf167b01333e584e0367aaf /t
parent4542dfad9d493f42e8b9c1c2b2da476f0e7ff815 (diff)
downloadiurt-435e218e4dcc413e1d74f1ad39c7882de5b9b7ee.tar
iurt-435e218e4dcc413e1d74f1ad39c7882de5b9b7ee.tar.gz
iurt-435e218e4dcc413e1d74f1ad39c7882de5b9b7ee.tar.bz2
iurt-435e218e4dcc413e1d74f1ad39c7882de5b9b7ee.tar.xz
iurt-435e218e4dcc413e1d74f1ad39c7882de5b9b7ee.zip
Allow overriding true config values with false
Diffstat (limited to 't')
-rw-r--r--t/config.t40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/config.t b/t/config.t
new file mode 100644
index 0000000..4ecb8a7
--- /dev/null
+++ b/t/config.t
@@ -0,0 +1,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();