X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fextindex-psgi.t;h=98dc2e48f313b6e0bd82274d0d0c16ed67375a0d;hb=21fcd8a37c82c1ef654d402cf592f0c9d803aa26;hp=6f62b5a035be0cd040a78876f8609116e4d5d4a7;hpb=be940983157a1f8bd353cb1891f6971645c73e5d;p=public-inbox.git diff --git a/t/extindex-psgi.t b/t/extindex-psgi.t index 6f62b5a0..98dc2e48 100644 --- a/t/extindex-psgi.t +++ b/t/extindex-psgi.t @@ -11,6 +11,7 @@ require_git(2.6); require_mods(qw(json DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test URI::Escape Plack::Builder)); use_ok($_) for (qw(HTTP::Request::Common Plack::Test)); +use IO::Uncompress::Gunzip qw(gunzip); require PublicInbox::WWW; my ($ro_home, $cfg_path) = setup_public_inboxes; my ($tmpdir, $for_destroy) = tmpdir; @@ -18,16 +19,19 @@ my $home = "$tmpdir/home"; mkdir $home or BAIL_OUT $!; mkdir "$home/.public-inbox" or BAIL_OUT $!; my $pi_config = "$home/.public-inbox/config"; -cp("$ro_home/.public-inbox/config", $pi_config) or BAIL_OUT; +cp($cfg_path, $pi_config) or BAIL_OUT; my $env = { HOME => $home }; run_script([qw(-extindex --all), "$tmpdir/eidx"], $env) or BAIL_OUT; { - open my $cfgfh, '>', $pi_config or BAIL_OUT; + open my $cfgfh, '>>', $pi_config or BAIL_OUT; $cfgfh->autoflush(1); print $cfgfh <new(PublicInbox::Config->new($pi_config)); @@ -40,6 +44,45 @@ my $client = sub { 'Host: header respected in Atom feed'); unlike($res->content, qr!http://bogus\.example\.com/!s, 'default URL ignored with different host header'); + + $res = $cb->(GET('/all/_/text/config/')); + is($res->code, 200, '/text/config HTML'); + $res = $cb->(GET('/all/_/text/config/raw')); + is($res->code, 200, '/text/config raw'); + my $f = "$tmpdir/extindex.config"; + open my $fh, '>', $f or xbail $!; + print $fh $res->content or xbail $!; + close $fh or xbail $!; + my $cfg = PublicInbox::Config->git_config_dump($f); + is($?, 0, 'no errors from git-config parsing'); + ok($cfg->{'extindex.all.topdir'}, 'extindex.topdir defined'); + + $res = $cb->(GET('/all/all.mbox.gz')); + is($res->code, 200, 'all.mbox.gz'); + + $res = $cb->(GET('/')); + like($res->content, qr!\Qhttp://bogus.example.com/all\E!, + '/all listed'); + $res = $cb->(GET('/?q=')); + is($res->code, 200, 'no query means all inboxes'); + $res = $cb->(GET('/?q=nonexistent')); + is($res->code, 404, 'no inboxes matched'); + unlike($res->content, qr!no inboxes, yet!, + 'we have inboxes, just no matches'); + + my $m = {}; + for my $pfx (qw(/t1 /t2), '') { + $res = $cb->(GET($pfx.'/manifest.js.gz')); + gunzip(\($res->content) => \(my $js)); + $m->{$pfx} = json_utf8->decode($js); + } + is_deeply([sort keys %{$m->{''}}], + [ sort(keys %{$m->{'/t1'}}, keys %{$m->{'/t2'}}) ], + 't1 + t2 = all'); + is_deeply([ sort keys %{$m->{'/t2'}} ], [ '/t2/git/0.git' ], + 't2 manifest'); + is_deeply([ sort keys %{$m->{'/t1'}} ], [ '/t1' ], + 't2 manifest'); }; test_psgi(sub { $www->call(@_) }, $client); %$env = (%$env, TMPDIR => $tmpdir, PI_CONFIG => $pi_config);