X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_search.t;h=3c515d19b67a11c218bb6d347eece293d0457fb9;hb=46742d95647c7a80cb2f60d5c134717dd91e22e2;hp=4cd0e499c1841035e72877feb22c9a0c75a513d1;hpb=fece7fca6aeac74410a813cffcb0da338017d0ed;p=public-inbox.git
diff --git a/t/psgi_search.t b/t/psgi_search.t
index 4cd0e499..3c515d19 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -1,24 +1,20 @@
-# Copyright (C) 2017-2019 all contributors
+# Copyright (C) 2017-2020 all contributors
# License: AGPL-3.0+
use strict;
use warnings;
use Test::More;
-use File::Temp qw/tempdir/;
-use Email::MIME;
+use PublicInbox::MIME;
use PublicInbox::Config;
use PublicInbox::Inbox;
use PublicInbox::InboxWritable;
-use PublicInbox::WWW;
use bytes (); # only for bytes::length
+use PublicInbox::TestCommon;
my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
URI::Escape Plack::Builder);
-foreach my $mod (@mods) {
- eval "require $mod";
- plan skip_all => "$mod missing for psgi_search.t" if $@;
-}
-
-use_ok $_ foreach (@mods, qw(PublicInbox::SearchIdx));
-my $tmpdir = tempdir('pi-psgi-search.XXXXXX', TMPDIR => 1, CLEANUP => 1);
+require_mods(@mods);
+use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
+use_ok 'PublicInbox::WWW';
+my ($tmpdir, $for_destroy) = tmpdir();
my $ibx = PublicInbox::Inbox->new({
inboxdir => $tmpdir,
@@ -31,16 +27,32 @@ my $im = $ibx->importer(0);
my $digits = '10010260936330';
my $ua = 'Pine.LNX.4.10';
my $mid = "$ua.$digits.2460-100000\@penguin.transmeta.com";
-my $data = <<"EOF";
+my $mime = PublicInbox::MIME->new(<
From: Ãvar Arnfjörð Bjarmason
To: git\@vger.kernel.org
EOF
+$im->add($mime);
+
+$mime = PublicInbox::MIME->new(<<'EOF');
+Subject:
+Message-ID:
+From: blank subject
+To: git@vger.kernel.org
-my $mime = Email::MIME->new(\$data);
+EOF
$im->add($mime);
+
+$mime = PublicInbox::MIME->new(<<'EOF');
+Message-ID:
+From: no subject at all
+To: git@vger.kernel.org
+
+EOF
+$im->add($mime);
+
$im->done;
PublicInbox::SearchIdx->new($ibx, 1)->index_sync;
@@ -82,6 +94,25 @@ test_psgi(sub { $www->call(@_) }, sub {
like($res->content, $mid_re, 'found mid in response');
chop($digits);
}
+
+ $res = $cb->(GET('/test/'));
+ $html = $res->content;
+ like($html, qr/\bhref="no-subject-at-all[^>]+>\(no subject\),
+ 'subject-less message linked from "/$INBOX/"');
+ like($html, qr/\bhref="blank-subject[^>]+>\(no subject\),
+ 'blank subject message linked from "/$INBOX/"');
+
+ $res = $cb->(GET('/test/?q=tc:git'));
+ like($html, qr/\bhref="no-subject-at-all[^>]+>\(no subject\),
+ 'subject-less message linked from "/$INBOX/?q=..."');
+ like($html, qr/\bhref="blank-subject[^>]+>\(no subject\),
+ 'blank subject message linked from "/$INBOX/?q=..."');
+ $res = $cb->(GET('/test/no-subject-at-all@example.com/raw'));
+ like($res->header('Content-Disposition'),
+ qr/filename=no-subject\.txt/);
+ $res = $cb->(GET('/test/no-subject-at-all@example.com/t.mbox.gz'));
+ like($res->header('Content-Disposition'),
+ qr/filename=no-subject\.mbox\.gz/);
});
done_testing();