]> Sergey Matveev's repositories - public-inbox.git/commitdiff
config: do not nest multi-value altid arrays
authorEric Wong <e@80x24.org>
Fri, 12 Aug 2016 02:15:55 +0000 (02:15 +0000)
committerEric Wong <e@80x24.org>
Fri, 12 Aug 2016 02:19:53 +0000 (02:19 +0000)
Oops.  We will inevitably need to support multiple altids for a
public-inbox one day.

lib/PublicInbox/Config.pm
t/config.t

index cd8854888c9dfe29e5ba0c96859d2a19bfc28c19..5eae1f1d105ab67decf7850d70f20cbf69a0d368 100644 (file)
@@ -147,7 +147,7 @@ sub _fill {
        }
        foreach my $k (qw(altid)) { # TODO: more arrays
                if (defined(my $v = $self->{"$pfx.$k"})) {
-                       $rv->{$k} = [ $v ];
+                       $rv->{$k} = ref($v) eq 'ARRAY' ? $v : [ $v ];
                }
        }
 
index 77e8f4ac18e5bd7b8b153a18326e12a5581690e6..073d1d03074db83d6054e11991910ccee7d1b66d 100644 (file)
@@ -50,4 +50,17 @@ my $tmpdir = tempdir('pi-config-XXXXXX', TMPDIR => 1, CLEANUP => 1);
        }, "lookup matches expected output for test");
 }
 
+
+{
+       my $cfgpfx = "publicinbox.test";
+       my @altid = qw(serial:gmane:file=a serial:enamg:file=b);
+       my $config = PublicInbox::Config->new({
+               "$cfgpfx.address" => 'test@example.com',
+               "$cfgpfx.mainrepo" => '/path/to/non/existent',
+               "$cfgpfx.altid" => [ @altid ],
+       });
+       my $ibx = $config->lookup_name('test');
+       is_deeply($ibx->{altid}, [ @altid ]);
+}
+
 done_testing();