about summary refs log tree commit homepage
path: root/t/extsearch.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-11-28 08:45:21 +0000
committerEric Wong <e@80x24.org>2020-11-29 02:25:39 +0000
commit50ac81092ba1034f3055ddabb3d7cc7853edfa41 (patch)
tree8662fcc2883fc4a145c0618e2ed197e943289c2c /t/extsearch.t
parent44de182766037948d62bc2a8ba924de2264dd5fc (diff)
downloadpublic-inbox-50ac81092ba1034f3055ddabb3d7cc7853edfa41.tar.gz
We need to completely remove a message from over.sqlite3 and
Xapian when no references remain, otherwise users will still see
the removed messages in NNTP overviews and WWW search
results/summaries.

References to messages are now solely handled by the `xref3'
table of over.sqlite3.  We can also trust `xref3' when deciding
whether to remove only the "O$eidx_key" and "G$lid" terms from a
document in Xapian or to remove the entire Xapian document.
Diffstat (limited to 't/extsearch.t')
-rw-r--r--t/extsearch.t20
1 files changed, 20 insertions, 0 deletions
diff --git a/t/extsearch.t b/t/extsearch.t
index f9f74e5c..f5855558 100644
--- a/t/extsearch.t
+++ b/t/extsearch.t
@@ -118,6 +118,26 @@ my $es = PublicInbox::ExtSearch->new("$home/extindex");
         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');
+
+        my $mset = $es->mset('b:"BEST MSG"');
+        is($mset->size, 1, 'new message found');
+        $mset = $es->mset('b:"test message"');
+        is($mset->size, 1, 'old message found');
+
+        delete @$es{qw(git over xdb)}; # fork preparation
+
+        open my $rmfh, '+>', undef or BAIL_OUT $!;
+        $rmfh->autoflush(1);
+        print $rmfh $eml2->as_string or BAIL_OUT $!;
+        seek($rmfh, 0, SEEK_SET) or BAIL_OUT $!;
+        $opt->{0} = $rmfh;
+        ok(run_script([qw(-learn rm --all)], undef, $opt), '-learn rm');
+
+        ok(run_script([qw(-extindex --all), "$home/extindex"], undef, undef),
+                'extindex after rm');
+        is($es->over->get_art(2), undef, 'doc #2 gone');
+        $mset = $es->mset('b:"BEST MSG"');
+        is($mset->size, 0, 'new message gone');
 }
 
 my $misc = $es->misc;