about summary refs log tree commit homepage
path: root/t/solver_git.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-10-04 19:12:35 +0000
committerEric Wong <e@80x24.org>2022-10-05 21:15:26 +0000
commit6dec9bf8c0e1b859703d7a5dfb87052cf4e87846 (patch)
tree7d0e0c7bf96da3a3fe494eaaaaf1c714b5aa1775 /t/solver_git.t
parenta002384a74382df2649d6a1f8dfba4f291af032e (diff)
downloadpublic-inbox-6dec9bf8c0e1b859703d7a5dfb87052cf4e87846.tar.gz
This will allow it to easily map a single coderepo to multiple
inboxes (or multiple coderepos to any number of inboxes).
For now, this is just a summary, but $REPO/$OID/s/ support
will be added, along with archive downloads.

Indexing of coderepos will probably be supported via -extindex,
only.
Diffstat (limited to 't/solver_git.t')
-rw-r--r--t/solver_git.t33
1 files changed, 32 insertions, 1 deletions
diff --git a/t/solver_git.t b/t/solver_git.t
index e347c711..d6936c47 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -9,7 +9,9 @@ require_git(2.6);
 use PublicInbox::ContentHash qw(git_sha);
 use PublicInbox::Spawn qw(popen_rd);
 require_mods(qw(DBD::SQLite Search::Xapian Plack::Util));
-my $git_dir = xqx([qw(git rev-parse --git-dir)], undef, {2 => \(my $null)});
+my $rdr = { 2 => \(my $null) };
+my $git_dir = xqx([qw(git rev-parse --git-common-dir)], undef, $rdr);
+$git_dir = xqx([qw(git rev-parse --git-dir)], undef, $rdr) if $? != 0;
 $? == 0 or plan skip_all => "$0 must be run from a git working tree";
 chomp $git_dir;
 
@@ -300,6 +302,35 @@ EOF
                 is($res->code, 200, 'shows commit w/ utf8.eml');
                 like($res->content, qr/El&#233;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');
         };
         test_psgi(sub { $www->call(@_) }, $client);
         my $env = { PI_CONFIG => $cfgpath, TMPDIR => $tmpdir };