diff options
author | Eric Wong <e@80x24.org> | 2020-11-29 05:09:35 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-11-29 06:42:00 +0000 |
commit | ea885bf0f76dc1795dc771667be721ec0fed5482 (patch) | |
tree | 5323da5926b6aa4c20619e2a05805f581722a389 /t/extsearch.t | |
parent | 33f80a367325f3dac983633cb0a59946205776c2 (diff) | |
download | public-inbox-ea885bf0f76dc1795dc771667be721ec0fed5482.tar.gz |
Inboxes may be removed or newsgroups renamed over time. Introduce a switch to do garbage collection and eliminate stale search and xref3 results based on inboxes which remain in the config file. This may also fixup stale results leftover from any bugs which may leave stale data around. This is also useful in case a clumsy BOFH (me :P) is swapping between several PI_CONFIGs and accidentally indexed a bunch of inboxes they didn't intend to.
Diffstat (limited to 't/extsearch.t')
-rw-r--r-- | t/extsearch.t | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/t/extsearch.t b/t/extsearch.t index 4f1dbadf..10b14baf 100644 --- a/t/extsearch.t +++ b/t/extsearch.t @@ -16,7 +16,8 @@ my $host_port = $sock->sockhost . ':' . $sock->sockport; my ($home, $for_destroy) = tmpdir(); local $ENV{HOME} = $home; mkdir "$home/.public-inbox" or BAIL_OUT $!; -open my $fh, '>', "$home/.public-inbox/config" or BAIL_OUT $!; +my $cfg_path = "$home/.public-inbox/config"; +open my $fh, '>', $cfg_path or BAIL_OUT $!; print $fh <<EOF or BAIL_OUT $!; [publicinboxMda] spamcheck = none @@ -55,7 +56,7 @@ ok(run_script([qw(-extindex --all), "$home/extindex"]), 'extindex init'); { # TODO: -extindex should write this to config - open $fh, '>>', "$home/.public-inbox/config" or BAIL_OUT $!; + open $fh, '>>', $cfg_path or BAIL_OUT $!; print $fh <<EOF or BAIL_OUT $!; ; for ->ALL [extindex "all"] @@ -148,4 +149,18 @@ is(scalar(@it), 2, 'two inboxes'); like($it[0]->get_document->get_data, qr/v2test/, 'docdata matched v2'); like($it[1]->get_document->get_data, qr/v1test/, 'docdata matched v1'); +if ('remove v1test and test gc') { + xsys([qw(git config --unset publicinbox.v1test.inboxdir)], + { GIT_CONFIG => $cfg_path }); + my $opt = { 2 => \(my $err = '') }; + ok(run_script([qw(-extindex --gc), "$home/extindex"], undef, $opt), + 'extindex --gc'); + like($err, qr/^I: remove #1 v1\.example /ms, 'removed v1 message'); + is(scalar(grep(!/^I:/, split(/^/m, $err))), 0, + 'no non-informational messages'); + $misc->{xdb}->reopen; + @it = $misc->mset('')->items; + is(scalar(@it), 1, 'only one inbox left'); +} + done_testing; |