- $res = $cb->(GET('/test/Z%40B/4-a.txt'));
- my $dot_res = $res->content;
- ok(length($dot_res) >= length($dot), 'dot almost matches');
- $res = $cb->(GET('/test/Z%40B/4-any-filename.txt'));
- is($res->content, $dot_res, 'user-specified filename is OK');
- });
+ $res = $cb->(GET("/test/$mid/2-embed2x.eml"));
+ my $eml = PublicInbox::Eml->new(\($res->content));
+ is_deeply([ $eml->header_raw('Message-ID') ], [ "<$irt>" ],
+ 'got attached eml');
+ my @subs = $eml->subparts;
+ is(scalar(@subs), 2, 'attachment had 2 subparts');
+ like($subs[0]->body_str, qr/^testing embedded message\n*\z/sm,
+ '1st attachment is as expected');
+ is($subs[1]->header('Content-Type'), 'message/rfc822',
+ '2nd attachment is as expected');
+
+ $res = $cb->(GET("/test/$mid/2.1.2-test.eml"));
+ $eml = PublicInbox::Eml->new(\($res->content));
+ is_deeply([ $eml->header_raw('Message-ID') ],
+ [ '<20200418214114.7575-1-e@yhbt.net>' ],
+ 'nested eml retrieved');
+};
+
+test_psgi(sub { $www->call(@_) }, $client);
+SKIP: {
+ require_mods(qw(DBD::SQLite Plack::Test::ExternalServer), 18);
+ $ibx = create_inbox 'test-indexed', indexlevel => 'basic', $creat_cb;
+ $cfgpath = "$ibx->{inboxdir}/pi_config";
+ my $env = { PI_CONFIG => $cfgpath };
+ $www = PublicInbox::WWW->new(PublicInbox::Config->new($cfgpath));
+ test_psgi(sub { $www->call(@_) }, $client);
+ my $sock = tcp_server() or die;
+ my ($tmpdir, $for_destroy) = tmpdir();
+ my ($out, $err) = map { "$tmpdir/std$_.log" } qw(out err);
+ my $cmd = [ qw(-httpd -W0), "--stdout=$out", "--stderr=$err" ];
+ my $td = start_script($cmd, $env, { 3 => $sock });
+ my ($h, $p) = tcp_host_port($sock);
+ local $ENV{PLACK_TEST_EXTERNALSERVER_URI} = "http://$h:$p";
+ Plack::Test::ExternalServer::test_psgi(client => $client);