From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 6/6] t/cgi.t: remove more redundant tests
Date: Fri, 4 Jan 2019 13:10:38 +0000 [thread overview]
Message-ID: <20190104131038.32233-7-e@80x24.org> (raw)
In-Reply-To: <20190104131038.32233-1-e@80x24.org>
Most of these test cases are in t/plack.t, already; and that
runs much faster. Just ensure the slashy corner case and search
stuff works. While we're at it, avoid using the
public-inbox-index command and just use the internal API to
index.
---
t/cgi.t | 36 +++++++++---------------------------
1 file changed, 9 insertions(+), 27 deletions(-)
diff --git a/t/cgi.t b/t/cgi.t
index e705cd7..aedd79e 100644
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -12,7 +12,6 @@ eval { require IPC::Run };
plan skip_all => "missing IPC::Run for t/cgi.t" if $@;
use constant CGI => "blib/script/public-inbox.cgi";
-my $index = "blib/script/public-inbox-index";
my $tmpdir = tempdir('pi-cgi-XXXXXX', TMPDIR => 1, CLEANUP => 1);
my $home = "$tmpdir/pi-home";
my $pi_home = "$home/.public-inbox";
@@ -77,14 +76,9 @@ Me wrote:
what?
EOF
$im->add($reply);
- $im->done;
-}
-# message-id pages
-{
- local $ENV{HOME} = $home;
my $slashy_mid = 'slashy/asdf@example.com';
- my $reply = Email::MIME->new(<<EOF);
+ my $slashy = Email::MIME->new(<<EOF);
From: You <you\@example.com>
To: Me <me\@example.com>
Cc: $addr
@@ -94,30 +88,12 @@ Date: Thu, 01 Jan 1970 00:00:01 +0000
slashy
EOF
- $im->add($reply);
+ $im->add($slashy);
$im->done;
my $res = cgi_run("/test/slashy/asdf\@example.com/raw");
like($res->{body}, qr/Message-Id: <\Q$slashy_mid\E>/,
"slashy mid raw hit");
-
- $res = cgi_run("/test/blahblah\@example.com/raw");
- like($res->{body}, qr/Message-Id: <blahblah\@example\.com>/,
- "mid raw hit");
-
- $res = cgi_run("/test/blahblah\@example.com/");
- like($res->{body}, qr/\A<html>/, "mid html hit");
- like($res->{head}, qr/Status: 200 OK/, "200 response");
-
- $res = cgi_run("/test/blahblah\@example.com/f/");
- like($res->{head}, qr/Status: 301 Moved/, "301 response");
- like($res->{head},
- qr!^Location: http://[^/]+/test/blahblah\@example\.com/\r\n!ms,
- '301 redirect location');
-
- $res = cgi_run("/test/new.html");
- like($res->{body}, qr/slashy%2Fasdf\@example\.com/,
- "slashy URL generated correctly");
}
# retrieve thread as an mbox
@@ -126,7 +102,13 @@ EOF
my $path = "/test/blahblah\@example.com/t.mbox.gz";
my $res = cgi_run($path);
like($res->{head}, qr/^Status: 501 /, "search not-yet-enabled");
- my $indexed = system($index, $maindir) == 0;
+ my $indexed;
+ eval {
+ require PublicInbox::SearchIdx;
+ my $s = PublicInbox::SearchIdx->new($maindir, 1);
+ $s->index_sync;
+ $indexed = 1;
+ };
if ($indexed) {
$res = cgi_run($path);
like($res->{head}, qr/^Status: 200 /, "search returned mbox");
--
EW
prev 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 ` [PATCH 4/6] t/cgi.t: move dumb HTTP git clone/fetch tests to plack.t Eric Wong
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 ` Eric Wong [this message]
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-7-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.
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).