From f89086d7013ae770157c2a01bd95c79d22de1a31 Mon Sep 17 00:00:00 2001
From: Eric Wong <e@80x24.org>
Date: Fri, 27 Nov 2020 09:52:51 +0000
Subject: [PATCH] t/extsearch: show a more realistic case

Different messages to different public Inboxes are likely to
have different List-IDs, so show that we can deduplicate based
on content (but per-mailing-list trailers need to go through a
PublicInbox::Filter::* or be disabled by mailing list admins).
---
 t/extsearch.t | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/t/extsearch.t b/t/extsearch.t
index 85cdf74a..778ba32d 100644
--- a/t/extsearch.t
+++ b/t/extsearch.t
@@ -25,14 +25,28 @@ my $v1addr = 'v1test@example.com';
 ok(run_script([qw(-init -V2 v2test --newsgroup v2.example), "$home/v2test",
 	'http://example.com/v2test', $v2addr ]), 'v2test init');
 my $env = { ORIGINAL_RECIPIENT => $v2addr };
-open($fh, '<', 't/utf8.eml') or BAIL_OUT("open t/utf8.eml: $!");
+my $eml = eml_load('t/utf8.eml');
+
+$eml->header_set('List-Id', '<v2.example.com>');
+open($fh, '+>', undef) or BAIL_OUT $!;
+$fh->autoflush(1);
+print $fh $eml->as_string or BAIL_OUT $!;
+seek($fh, 0, SEEK_SET) or BAIL_OUT $!;
+
 run_script(['-mda', '--no-precheck'], $env, { 0 => $fh }) or BAIL_OUT '-mda';
 
 ok(run_script([qw(-init -V1 v1test), "$home/v1test",
 	'http://example.com/v1test', $v1addr ]), 'v1test init');
-$env = { ORIGINAL_RECIPIENT => $v1addr };
+
+$eml->header_set('List-Id', '<v1.example.com>');
 seek($fh, 0, SEEK_SET) or BAIL_OUT $!;
+truncate($fh, 0) or BAIL_OUT $!;
+print $fh $eml->as_string or BAIL_OUT $!;
+seek($fh, 0, SEEK_SET) or BAIL_OUT $!;
+
+$env = { ORIGINAL_RECIPIENT => $v1addr };
 run_script(['-mda', '--no-precheck'], $env, { 0 => $fh }) or BAIL_OUT '-mda';
+
 run_script(['-index', "$home/v1test"]) or BAIL_OUT "index $?";
 
 ok(run_script([qw(-extindex --all), "$home/extindex"]), 'extindex init');
-- 
2.50.0