]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/config.t
config: support multiple addresses for a inbox
[public-inbox.git] / t / config.t
index 7dddd2e8edd0ef9af37defad97be164aed76586b..cd61fe091d2d607dfde12f2c286e4ef0b4becf75 100644 (file)
@@ -8,16 +8,42 @@ use File::Temp qw/tempdir/;
 my $tmpdir = tempdir(CLEANUP => 1);
 
 {
-       is(system(qw(git init --bare), $tmpdir), 0, "git init successful");
+       is(system(qw(git init -q --bare), $tmpdir), 0, "git init successful");
        {
                local $ENV{GIT_DIR} = $tmpdir;
                is(system(qw(git config foo.bar hihi)), 0, "set config");
        }
 
-       my $tmp = PublicInbox::Config->dump("$tmpdir/config");
+       my $tmp = PublicInbox::Config->new("$tmpdir/config");
 
        is("hihi", $tmp->{"foo.bar"}, "config read correctly");
        is("true", $tmp->{"core.bare"}, "used --bare repo");
 }
 
+{
+       my $f = "examples/public-inbox-config";
+       ok(-r $f, "$f is readable");
+
+       my $cfg = PublicInbox::Config->new($f);
+       is_deeply($cfg->lookup('bugs@public-inbox.org'), {
+               'mainrepo' => '/home/pi/bugs-main.git',
+               'address' => 'bugs@public-inbox.org',
+               'description' => 'development discussion',
+               'listname' => 'bugs',
+       }, "lookup matches expected output");
+
+       is($cfg->lookup('blah@example.com'), undef,
+               "non-existent lookup returns undef");
+
+       my $test = $cfg->lookup('test@public-inbox.org');
+       is_deeply($test, {
+               'address' => ['try@public-inbox.org',
+                             'sandbox@public-inbox.org',
+                             'test@public-inbox.org'],
+               'mainrepo' => '/home/pi/test-main.git',
+               'description' => 'test/sandbox area, occasionally reset',
+               'listname' => 'test',
+       }, "lookup matches expected output for test");
+}
+
 done_testing();