1 # Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
6 use PublicInbox::Config;
7 use File::Temp qw/tempdir/;
8 my $tmpdir = tempdir(CLEANUP => 1);
11 is(system(qw(git init -q --bare), $tmpdir), 0, "git init successful");
13 local $ENV{GIT_DIR} = $tmpdir;
14 is(system(qw(git config foo.bar hihi)), 0, "set config");
17 my $tmp = PublicInbox::Config->new("$tmpdir/config");
19 is("hihi", $tmp->{"foo.bar"}, "config read correctly");
20 is("true", $tmp->{"core.bare"}, "used --bare repo");
24 my $f = "examples/public-inbox-config";
25 ok(-r $f, "$f is readable");
27 my $cfg = PublicInbox::Config->new($f);
28 is_deeply($cfg->lookup('bugs@public-inbox.org'), {
29 'mainrepo' => '/home/pi/bugs-main.git',
30 'address' => 'bugs@public-inbox.org',
31 'description' => 'development discussion'
32 }, "lookup matches expected output");
34 is($cfg->lookup('blah@example.com'), undef,
35 "non-existent lookup returns undef");