]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/extsearch.t
nntp: make ->ALL Xref generation more fuzzy
[public-inbox.git] / t / extsearch.t
index 4f1dbadf8d60d28fecbdce872d46fddbc1d86f10..2b8b88ea2697ff104e0a8495d480545caad2c5fb 100644 (file)
@@ -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
@@ -52,10 +53,13 @@ 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');
-
+{
+       my $es = PublicInbox::ExtSearch->new("$home/extindex");
+       ok($es->has_threadid, '->has_threadid');
+}
 
 { # 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"]
@@ -68,7 +72,8 @@ EOF
        ok($pi_cfg->ALL, '->ALL');
        my $ibx = $pi_cfg->{-by_newsgroup}->{'v2.example'};
        my $ret = $pi_cfg->ALL->nntp_xref_for($ibx, $ibx->over->get_art(1));
-       is_deeply($ret, ['v1.example:1'], '->nntp_xref_for');
+       is_deeply($ret, { 'v1.example' => 1, 'v2.example' => 1 },
+               '->nntp_xref_for');
 }
 
 SKIP: {
@@ -148,4 +153,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;