about summary refs log tree commit homepage
path: root/t/init.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-07-21 14:05:50 +0000
committerEric Wong <e@80x24.org>2021-07-22 02:28:46 +0000
commit7e1c18af5468c7708e28de759911ec5542d23c4b (patch)
tree2906f5775e749385bc1acae1bca896f3687564ef /t/init.t
parent5666a78ea0a34d4b8292ee335e12af1452f7fe83 (diff)
downloadpublic-inbox-7e1c18af5468c7708e28de759911ec5542d23c4b.tar.gz
This won't blindly append identical key=values, but
allows specifying multiple, different key=value pairs
as long as the values are different.
Diffstat (limited to 't/init.t')
-rw-r--r--t/init.t34
1 files changed, 34 insertions, 0 deletions
diff --git a/t/init.t b/t/init.t
index d46bef23..7382e05b 100644
--- a/t/init.t
+++ b/t/init.t
@@ -48,6 +48,40 @@ sub quiet_fail {
         is($? >> 8, 255, 'got expected exit code on lock failure');
         ok(unlink("$cfgfile.lock"),
                 '-init did not unlink lock on failure');
+
+        my @init_args = ('i', "$tmpdir/i",
+                   qw(http://example.com/i i@example.com));
+        $cmd = [ qw(-init -c .bogus=val), @init_args ];
+        quiet_fail($cmd, 'invalid -c KEY=VALUE fails');
+        $cmd = [ qw(-init -c .bogus=val), @init_args ];
+        quiet_fail($cmd, '-c KEY-only fails');
+        $cmd = [ qw(-init -c address=clist@example.com), @init_args ];
+        quiet_fail($cmd, '-c address=CONFLICTING-VALUE fails');
+
+        $cmd = [ qw(-init -c no=problem -c no=problemo), @init_args ];
+        ok(run_script($cmd), '-c KEY=VALUE runs');
+        my $env = { GIT_CONFIG => "$ENV{PI_DIR}/config" };
+        chomp(my @v = xqx([qw(git config --get-all publicinbox.i.no)], $env));
+        is_deeply(\@v, [ qw(problem problemo) ]) or xbail(\@v);
+
+        ok(run_script($cmd), '-c KEY=VALUE runs idempotently');
+        chomp(my @v2 = xqx([qw(git config --get-all publicinbox.i.no)], $env));
+        is_deeply(\@v, \@v2, 'nothing repeated') or xbail(\@v2);
+
+        ok(run_script([@$cmd, '-c', 'no=more']), '-c KEY=VALUE addendum');
+        chomp(@v = xqx([qw(git config --get-all publicinbox.i.no)], $env));
+        is_deeply(\@v, [ qw(problem problemo more) ]) or xbail(\@v);
+
+
+        ok(run_script([@$cmd, '-c', 'no=problem']), '-c KEY=VALUE repeated');
+        chomp(@v = xqx([qw(git config --get-all publicinbox.i.no)], $env));
+        is_deeply(\@v, [ qw(problem problemo more) ]) or xbail(\@v);
+
+        ok(run_script([@$cmd, '-c', 'address=j@example.com']),
+                '-c KEY=VALUE address');
+        chomp(@v = xqx([qw(git config --get-all publicinbox.i.address)], $env));
+        is_deeply(\@v, [ qw(i@example.com j@example.com) ],
+                'extra address added via -c KEY=VALUE');
 }
 {
         my $env = { PI_DIR => "$tmpdir/.public-inbox/" };