]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/solver_git.t
t/nntp.t: fix parse_time test for non-GMT local time
[public-inbox.git] / t / solver_git.t
index 4cadd06adf10acdca5613713f94a400a30599f13..55746994d9f94cc887d2b5c71f46315f73cb9445 100644 (file)
@@ -127,7 +127,7 @@ SKIP: {
        while (my ($label, $size) = each %bin) {
                pipe(my ($rout, $wout)) or die;
                pipe(my ($rin, $win)) or die;
-               my $rdr = { 0 => fileno($rin), 1 => fileno($wout) };
+               my $rdr = { 0 => $rin, 1 => $wout };
                my $pid = spawn($cmd , $env, $rdr);
                $wout = $rin = undef;
                print { $win } ("\0" x $size) or die;
@@ -138,18 +138,27 @@ SKIP: {
        # ensure the PSGI frontend (ViewVCS) works:
        my $name = $ibx->{name};
        my $cfgpfx = "publicinbox.$name";
-       my $cfg = PublicInbox::Config->new(\<<EOF);
-$cfgpfx.address=$ibx->{address};
-$cfgpfx.inboxdir=$inboxdir
-$cfgpfx.coderepo=public-inbox
-$cfgpfx.coderepo=binfoo
-coderepo.public-inbox.dir=$git_dir
-coderepo.public-inbox.cgiturl=http://example.com/public-inbox
-coderepo.binfoo.dir=$binfoo
-coderepo.binfoo.cgiturl=http://example.com/binfoo
+       my $cfgpath = "$inboxdir/httpd-config";
+       open my $cfgfh, '>', $cfgpath or die;
+       print $cfgfh <<EOF or die;
+[publicinbox "$name"]
+       address = $ibx->{address};
+       inboxdir = $inboxdir
+       coderepo = public-inbox
+       coderepo = binfoo
+       url = http://example.com/$name
+[coderepo "public-inbox"]
+       dir = $git_dir
+       cgiturl = http://example.com/public-inbox
+[coderepo "binfoo"]
+       dir = $binfoo
+       cgiturl = http://example.com/binfoo
 EOF
+       close $cfgfh or die;
+       my $cfg = PublicInbox::Config->new($cfgpath);
        my $www = PublicInbox::WWW->new($cfg);
-       test_psgi(sub { $www->call(@_) }, sub {
+       my $non_existent = 'ee5e32211bf62ab6531bdf39b84b6920d0b6775a';
+       my $client = sub {
                my ($cb) = @_;
                my $res = $cb->(GET("/$name/3435775/s/"));
                is($res->code, 200, 'success with existing blob');
@@ -157,6 +166,9 @@ EOF
                $res = $cb->(GET("/$name/".('0'x40).'/s/'));
                is($res->code, 404, 'failure with null OID');
 
+               $res = $cb->(GET("/$name/$non_existent/s/"));
+               is($res->code, 404, 'failure with null OID');
+
                $res = $cb->(GET("/$name/$v1_0_0_tag/s/"));
                is($res->code, 200, 'shows commit');
                while (my ($label, $size) = each %bin) {
@@ -169,7 +181,19 @@ EOF
                        is($res->content, "\0" x $size,
                                "$label content matches");
                }
-       });
+       };
+       test_psgi(sub { $www->call(@_) }, $client);
+       SKIP: {
+               require_mods(qw(Plack::Test::ExternalServer), 7);
+               my $env = { PI_CONFIG => $cfgpath };
+               my $sock = tcp_server() or die;
+               my ($out, $err) = map { "$inboxdir/std$_.log" } qw(out err);
+               my $cmd = [ qw(-httpd -W0), "--stdout=$out", "--stderr=$err" ];
+               my $td = start_script($cmd, $env, { 3 => $sock });
+               my ($h, $p) = ($sock->sockhost, $sock->sockport);
+               local $ENV{PLACK_TEST_EXTERNALSERVER_URI} = "http://$h:$p";
+               Plack::Test::ExternalServer::test_psgi(client => $client);
+       }
 }
 
 done_testing();