]> Sergey Matveev's repositories - public-inbox.git/commitdiff
xt/mem-msgview.t: change to test one multipart message
authorEric Wong <e@yhbt.net>
Sat, 11 Jan 2020 06:28:15 +0000 (06:28 +0000)
committerEric Wong <e@yhbt.net>
Sun, 12 Jan 2020 21:26:38 +0000 (21:26 +0000)
A single multipart message is far more common than
a reused Message-ID, so rewrite the test to only have
a single multipart message.  Memory improvements will
be implemented in the next commit.

xt/mem-msgview.t

index 0c3ad71070bb595f59811f1b3f070ee377c11918..bffb1768b9e57cafcd135b16a69b8232296480da 100644 (file)
@@ -1,6 +1,8 @@
 #!perl -w
 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+# Note: this may be altered as-needed to demonstrate improvements.
+# See history in git for this file.
 use strict;
 use IO::Handle; # ->flush
 use Fcntl qw(SEEK_SET);
@@ -10,7 +12,7 @@ use Test::More;
 my @mods = qw(DBD::SQLite BSD::Resource PublicInbox::WWW);
 require_mods(@mods);
 use_ok($_) for @mods;
-my $lines = $ENV{NR_LINES} // 100000;
+my $lines = $ENV{NR_LINES} // 50000;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $inboxname = 'big';
 my $inboxdir = "$tmpdir/big";
@@ -31,29 +33,39 @@ EOF
                'inbox initialized');
 
        $fh = tmpfile('big.eml', undef, my $append = 1) or die;
-       printf($fh <<'EOF', $addr, $mid) or die;
+       my $hdr = sprintf(<<'EOF', $addr, $mid);
 From: Dr. X <x@example.com>
 To: Nikki <%s>
 Date: Tue, 3 May 1988 00:00:00 +0000
 Subject: todo
 Message-ID: <%s>
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="FOO"
+Content-Disposition: inline
+
+--FOO
+Content-Type: text/plain; charset=utf-8
+Content-Disposition: inline
+
+EOF
+       print $fh $hdr or die;
+       for (0..$lines) { print $fh 'x' x 72, "\n" or die }
+       print $fh <<EOF or die;
+
+--FOO
+Content-Type: text/plain; charset=utf-8
+Content-Disposition: inline
 
 EOF
        for (0..$lines) { print $fh 'x' x 72, "\n" or die }
+       print $fh "\n--FOO--\n" or die;
        $fh->flush or die;
        sysseek($fh, 0, SEEK_SET) or die;
        my $env = { ORIGINAL_RECIPIENT => $addr };
        my $err = '';
        my $opt = { 0 => $fh, 2 => \$err, run_mode => 0 };
        ok(run_script([qw(-mda --no-precheck)], $env, $opt),
-               '1st message delivered');
-
-       # resend the message with same mid but different content
-       print $fh "mindcrime\n" or die;
-       $fh->flush or die;
-       sysseek($fh, 0, SEEK_SET) or die;
-       ok(run_script([qw(-mda --no-precheck)], $env, $opt),
-               '2nd message delivered');
+               'message delivered');
 }
 
 my $www = PublicInbox::WWW->new;