user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
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	[thread overview]
Message-ID: <20190104131038.32233-5-e@80x24.org> (raw)
In-Reply-To: <20190104131038.32233-1-e@80x24.org>

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


  parent reply	other threads:[~2019-01-04 13:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 13:10 [PATCH 0/6] t/cgi.t: test speedups and cleanups Eric Wong
2019-01-04 13:10 ` [PATCH 1/6] t/cgi.t: eliminate some cruft and unnecessary tests Eric Wong
2019-01-04 13:10 ` [PATCH 2/6] t/cgi.t: remove redundant redirect check Eric Wong
2019-01-04 13:10 ` [PATCH 3/6] t/cgi.t: remove atom.xml test Eric Wong
2019-01-04 13:10 ` Eric Wong [this message]
2019-01-04 13:10 ` [PATCH 5/6] t/cgi.t: move expected failure tests to t/plack.t Eric Wong
2019-01-04 13:10 ` [PATCH 6/6] t/cgi.t: remove more redundant tests Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190104131038.32233-5-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).