about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-10-27 07:54:48 +0000
committerEric Wong <e@80x24.org>2020-11-07 10:22:08 +0000
commit9ebb1544ac677d3ed37231cfd78624916b6f2945 (patch)
tree2dc963068e6053ffa0a6343168d28161599599b0 /t
parenta624577bd7417759b7428266da7e6f5a3413bc8e (diff)
downloadpublic-inbox-9ebb1544ac677d3ed37231cfd78624916b6f2945.tar.gz
We can now handle cases where messages are edited in one inbox
but not another, bifurcating the message.

V2Writable::log_range handles some edge-cases which could happen
in v2-only code paths, as well, but weren't usually triggered
due to default git-gc knobs not pruning immediately
Diffstat (limited to 't')
-rw-r--r--t/extsearch.t28
1 files changed, 27 insertions, 1 deletions
diff --git a/t/extsearch.t b/t/extsearch.t
index 108ffaeb..8d2c1507 100644
--- a/t/extsearch.t
+++ b/t/extsearch.t
@@ -35,8 +35,8 @@ run_script(['-index', "$home/v1test"]) or BAIL_OUT "index $?";
 
 ok(run_script([qw(-eindex --all), "$home/eindex"]), 'eindex init');
 
+my $es = PublicInbox::ExtSearch->new("$home/eindex");
 {
-        my $es = PublicInbox::ExtSearch->new("$home/eindex");
         my $smsg = $es->over->get_art(1);
         ok($smsg, 'got first article');
         is($es->over->get_art(2), undef, 'only one added');
@@ -46,4 +46,30 @@ ok(run_script([qw(-eindex --all), "$home/eindex"]), 'eindex init');
         is(scalar(@$xref3), 2, 'only to entries');
 }
 
+{
+        my ($in, $out, $err);
+        $in = $out = $err = '';
+        my $opt = { 0 => \$in, 1 => \$out, 2 => \$err };
+        my $env = { MAIL_EDITOR => "$^X -i -p -e 's/test message/BEST MSG/'" };
+        my $cmd = [ qw(-edit -Ft/utf8.eml), "$home/v2test" ];
+        ok(run_script($cmd, $env, $opt), '-edit');
+        ok(run_script([qw(-eindex --all), "$home/eindex"], undef, $opt),
+                'eindex again');
+        like($err, qr/discontiguous range/, 'warned about discontiguous range');
+        my $msg1 = $es->over->get_art(1) or BAIL_OUT 'msg1 missing';
+        my $msg2 = $es->over->get_art(2) or BAIL_OUT 'msg2 missing';
+        is($msg1->{mid}, $msg2->{mid}, 'edited message indexed');
+        isnt($msg1->{blob}, $msg2->{blob}, 'blobs differ');
+        my $eml2 = $es->smsg_eml($msg2);
+        like($eml2->body, qr/BEST MSG/, 'edited body in #2');
+        unlike($eml2->body, qr/test message/, 'old body discarded in #2');
+        my $eml1 = $es->smsg_eml($msg1);
+        like($eml1->body, qr/test message/, 'original body in #1');
+        my $x1 = $es->over->get_xref3(1);
+        my $x2 = $es->over->get_xref3(2);
+        is(scalar(@$x1), 1, 'original only has one xref3');
+        is(scalar(@$x2), 1, 'new message has one xref3');
+        isnt($x1->[0], $x2->[0], 'xref3 differs');
+}
+
 done_testing;