]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/cgi.t: move dumb HTTP git clone/fetch tests to plack.t
authorEric Wong <e@80x24.org>
Fri, 4 Jan 2019 09:14:48 +0000 (09:14 +0000)
committerEric Wong <e@80x24.org>
Fri, 4 Jan 2019 09:16:04 +0000 (09:16 +0000)
No need to test this via CGI .cgi is a wrapper around
PSGI and PSGI tests are way faster.

t/cgi.t
t/plack.t

diff --git a/t/cgi.t b/t/cgi.t
index 382c21fc52e263da108eb6316498799b98f6d563..a25d2eeb26bc7f7078d721233b83636da8c33c8c 100644 (file)
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -90,25 +90,6 @@ EOF
        like($res->{head}, qr/Status:\s*404/i, "index returns 404");
 }
 
-# dumb HTTP support
-{
-       local $ENV{HOME} = $home;
-       my $path = "/test/info/refs";
-       my $res = cgi_run($path);
-       like($res->{head}, qr/Status:\s*200/i, "info/refs readable");
-       my $orig = $res->{body};
-
-       local $ENV{HTTP_RANGE} = 'bytes=5-10';
-       $res = cgi_run($path);
-       like($res->{head}, qr/Status:\s*206/i, "info/refs partial OK");
-       is($res->{body}, substr($orig, 5, 6), 'partial body OK');
-
-       local $ENV{HTTP_RANGE} = 'bytes=5-';
-       $res = cgi_run($path);
-       like($res->{head}, qr/Status:\s*206/i, "info/refs partial past end OK");
-       is($res->{body}, substr($orig, 5), 'partial body OK past end');
-}
-
 # message-id pages
 {
        local $ENV{HOME} = $home;
index 1a719b41c6f2f7c4ffb73e03dacce3f8fcf93475..14c9b657f50cb5db1d3758ab693b89cfc533b484 100644 (file)
--- a/t/plack.t
+++ b/t/plack.t
@@ -220,6 +220,26 @@ EOF
                                'redirect from x40 MIDs works');
                }
        });
+
+       # dumb HTTP clone/fetch support
+       test_psgi($app, sub {
+               my ($cb) = @_;
+               my $path = '/test/info/refs';
+               my $req = HTTP::Request->new('GET' => $path);
+               my $res = $cb->($req);
+               is(200, $res->code, 'refs readable');
+               my $orig = $res->content;
+
+               $req->header('Range', 'bytes=5-10');
+               $res = $cb->($req);
+               is(206, $res->code, 'got partial response');
+               is($res->content, substr($orig, 5, 6), 'partial body OK');
+
+               $req->header('Range', 'bytes=5-');
+               $res = $cb->($req);
+               is(206, $res->code, 'got partial another response');
+               is($res->content, substr($orig, 5), 'partial body OK past end');
+       });
 }
 
 done_testing();