X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_search.t;h=64f8b1ac5c8378f6ce88a783f8bdcc86369efbd6;hb=0283273a14e1871955f6a9132f4f3f7884ec8a3f;hp=534063f8ed5206bbd8229dd92699973c2270cde1;hpb=cd8dd7b08fddc7c2b5f218c3fcaa5dca5f9ad945;p=public-inbox.git diff --git a/t/psgi_search.t b/t/psgi_search.t index 534063f8..64f8b1ac 100644 --- a/t/psgi_search.t +++ b/t/psgi_search.t @@ -1,19 +1,19 @@ -# 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'; my ($tmpdir, $for_destroy) = tmpdir(); my $ibx = PublicInbox::Inbox->new({ @@ -27,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::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 +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\)]+>\(no subject\)(GET('/test/?q=tc:git')); + like($html, qr/\bhref="no-subject-at-all[^>]+>\(no subject\)]+>\(no subject\)(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();