From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EC7A52141A for ; Fri, 4 Jan 2019 13:10:41 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/6] t/cgi.t: move dumb HTTP git clone/fetch tests to plack.t Date: Fri, 4 Jan 2019 13:10:36 +0000 Message-Id: <20190104131038.32233-5-e@80x24.org> In-Reply-To: <20190104131038.32233-1-e@80x24.org> References: <20190104131038.32233-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No need to test this via CGI .cgi is a wrapper around PSGI and PSGI tests are way faster. --- t/cgi.t | 19 ------------------- t/plack.t | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/t/cgi.t b/t/cgi.t index 382c21f..a25d2ee 100644 --- 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; diff --git a/t/plack.t b/t/plack.t index 1a719b4..14c9b65 100644 --- 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(); -- EW