]> Sergey Matveev's repositories - public-inbox.git/blob - t/psgi_multipart_not.t
config: we always have {-section_order}
[public-inbox.git] / t / psgi_multipart_not.t
1 # Copyright (C) 2018-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 use strict;
4 use warnings;
5 use Test::More;
6 use File::Temp qw/tempdir/;
7 use Email::MIME;
8 use PublicInbox::Config;
9 use PublicInbox::WWW;
10 my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common
11               Plack::Test URI::Escape Plack::Builder Plack::Test);
12 foreach my $mod (@mods) {
13         eval "require $mod";
14         plan skip_all => "$mod missing for psgi_multipart_not.t" if $@;
15 }
16 use_ok($_) for @mods;
17 use_ok 'PublicInbox::V2Writable';
18 my $repo = tempdir('pi-psgi-multipart-not.XXXXXX', TMPDIR => 1, CLEANUP => 1);
19 my $ibx = PublicInbox::Inbox->new({
20         mainrepo => $repo,
21         name => 'multipart-not',
22         version => 2,
23         -primary_address => 'test@example.com',
24 });
25 my $im = PublicInbox::V2Writable->new($ibx, 1);
26 $im->{parallel} = 0;
27
28 my $mime = PublicInbox::MIME->new(<<'EOF');
29 Message-Id: <200308111450.h7BEoOu20077@mail.osdl.org>
30 To: linux-kernel@vger.kernel.org
31 Subject: [OSDL] linux-2.6.0-test3 reaim results
32 Mime-Version: 1.0
33 Content-Type: multipart/mixed ;
34         boundary="==_Exmh_120757360"
35 Date: Mon, 11 Aug 2003 07:50:24 -0700
36 From: exmh user <x@example.com>
37
38 Freed^Wmultipart ain't what it used to be
39 EOF
40
41 ok($im->add($mime), 'added broken multipart message');
42 $im->done;
43
44 my $cfgpfx = "publicinbox.v2test";
45 my $cfg = <<EOF;
46 $cfgpfx.address=$ibx->{-primary_address}
47 $cfgpfx.mainrepo=$repo
48 EOF
49 my $config = PublicInbox::Config->new(\$cfg);
50 my $www = PublicInbox::WWW->new($config);
51
52 my ($res, $raw);
53 test_psgi(sub { $www->call(@_) }, sub {
54         my ($cb) = @_;
55         for my $u ('/v2test/?q=%22ain\'t what it used to be%22&x=t',
56                    '/v2test/new.atom', '/v2test/new.html') {
57                 $res = $cb->(GET($u));
58                 $raw = $res->content;
59                 ok(index($raw, 'Freed^Wmultipart') >= 0, $u);
60                 ok(index($raw, 'Warning: decoded text') >= 0, $u.' warns');
61         }
62 });
63
64 done_testing();
65 1;