+ my $utf8 = 'e022d3377fd2c50fd9931bf96394728958a90bf3';
+ $res = $cb->(GET("/$name/$utf8/s/"));
+ is($res->code, 200, 'shows commit w/ utf8.eml');
+ like($res->content, qr/Eléanor/,
+ 'UTF-8 commit shown properly');
+
+ # WwwCoderepo
+ my $olderr;
+ if (defined $ENV{PLACK_TEST_EXTERNALSERVER_URI}) {
+ ok(!-s "$tmpdir/stderr.log",
+ 'nothing in stderr.log, yet');
+ } else {
+ open $olderr, '>&', \*STDERR or xbail "open: $!";
+ open STDERR, '+>>', "$tmpdir/stderr.log" or
+ xbail "open: $!";
+ }
+ $res = $cb->(GET('/binfoo/'));
+ defined($ENV{PLACK_TEST_EXTERNALSERVER_URI}) or
+ open STDERR, '>&', $olderr or xbail "open: $!";
+ is($res->code, 200, 'coderepo summary (binfoo)');
+ if (ok(-s "$tmpdir/stderr.log")) {
+ open my $fh, '<', "$tmpdir/stderr.log" or xbail $!;
+ my $s = do { local $/; <$fh> };
+ open $fh, '>', "$tmpdir/stderr.log" or xbail $!;
+ ok($s =~ s/^fatal: your current branch.*?\n//sm,
+ 'got current branch warning');
+ ok($s =~ s/^.*? exit status=[1-9]+ .*?\n//sm,
+ 'got exit status warning');
+ is($s, '', 'no unexpected warnings on empty coderepo');
+ }
+ $res = $cb->(GET('/public-inbox/'));
+ is($res->code, 200, 'coderepo summary (public-inbox)');
+ $res = $cb->(GET('/public-inbox'));
+ is($res->code, 301, 'redirected');
+
+ my $fn = 'public-inbox-1.0.0.tar.gz';
+ $res = $cb->(GET("/public-inbox/snapshot/$fn"));
+ is($res->code, 200, 'tar.gz snapshot');
+ is($res->header('Content-Disposition'),
+ qq'inline; filename="$fn"', 'c-d header');
+ is($res->header('ETag'), qq'"$v1_0_0_rev"', 'etag header');
+
+ my $got = $res->content;
+ is(git_sha(256, \$got)->hexdigest, $exp_digest,
+ "content matches installed `git archive' output");
+ undef $got;
+
+ $fn = 'public-inbox-1.0.2.tar.gz';
+ $res = $cb->(GET("/public-inbox/snapshot/$fn"));
+ is($res->code, 404, '404 on non-existent tag');
+
+ $fn = 'public-inbox-1.0.0.tar.bz2';
+ $res = $cb->(GET("/public-inbox/snapshot/$fn"));
+ is($res->code, 404, '404 on unconfigured snapshot format');
+
+ $res = $cb->(GET('/public-inbox/atom/'));
+ is($res->code, 200, 'Atom feed');
+ SKIP: {
+ require_mods('XML::TreePP', 1);
+ my $t = XML::TreePP->new->parse($res->content);
+ is(scalar @{$t->{feed}->{entry}}, 50,
+ 'got 50 entries');
+
+ $res = $cb->(GET('/public-inbox/atom/COPYING'));
+ is($res->code, 200, 'file Atom feed');
+ $t = XML::TreePP->new->parse($res->content);
+ ok($t->{feed}->{entry}, 'got entry');
+
+ $res = $cb->(GET('/public-inbox/atom/README.md'));
+ is($res->code, 404, '404 on non-existent file Atom feed');
+ }
+ };
+ test_psgi(sub { $www->call(@_) }, $client);
+ my $env = { PI_CONFIG => $cfgpath, TMPDIR => $tmpdir };
+ test_httpd($env, $client, 7, sub {
+ SKIP: {
+ require_cmd('curl', 1) or skip 'no curl', 1;
+ mkdir "$tmpdir/ext" // xbail "mkdir $!";
+ my $rurl = "$ENV{PLACK_TEST_EXTERNALSERVER_URI}/$name";
+ test_lei({tmpdir => "$tmpdir/ext"}, sub {
+ lei_ok(qw(blob --no-mail 69df7d5 -I), $rurl);
+ is(git_sha(1, \$lei_out)->hexdigest, $expect,
+ 'blob contents output');
+ ok(!lei(qw(blob -I), $rurl, $non_existent),
+ 'non-existent blob fails');
+ });
+ }});