From: Eric Wong Date: Fri, 12 Aug 2016 02:15:55 +0000 (+0000) Subject: config: do not nest multi-value altid arrays X-Git-Tag: v1.0.0~240 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=b0f783fe601cfcaf89b30de461a540434f63b3ee;p=public-inbox.git config: do not nest multi-value altid arrays Oops. We will inevitably need to support multiple altids for a public-inbox one day. --- diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index cd885488..5eae1f1d 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -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 ]; } } diff --git a/t/config.t b/t/config.t index 77e8f4ac..073d1d03 100644 --- a/t/config.t +++ b/t/config.t @@ -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();