X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_search.t;h=2d12ba6a2c6a886e7db9019024a2dd13a47c26d5;hb=0faddbbfecaa784c584d3a625628c288fe9316c7;hp=534063f8ed5206bbd8229dd92699973c2270cde1;hpb=cd8dd7b08fddc7c2b5f218c3fcaa5dca5f9ad945;p=public-inbox.git
diff --git a/t/psgi_search.t b/t/psgi_search.t
index 534063f8..2d12ba6a 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -1,19 +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 Email::MIME;
+use PublicInbox::Eml;
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);
require_mods(@mods);
use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
+use_ok 'PublicInbox::WWW';
+use_ok 'PublicInbox::SearchIdx';
my ($tmpdir, $for_destroy) = tmpdir();
my $ibx = PublicInbox::Inbox->new({
@@ -27,16 +28,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::Eml->new(<
From: Ãvar Arnfjörð Bjarmason
To: git\@vger.kernel.org
EOF
+$im->add($mime);
+
+$mime = PublicInbox::Eml->new(<<'EOF');
+Subject:
+Message-ID:
+From: blank subject
+To: git@vger.kernel.org
+
+EOF
+$im->add($mime);
-my $mime = Email::MIME->new(\$data);
+$mime = PublicInbox::Eml->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;
@@ -78,6 +95,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();