]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/extsearch.t
rename {pi_config} fields to {pi_cfg}
[public-inbox.git] / t / extsearch.t
index 10b14baf19f1cfac16c5cb2aa444ab74657db878..97786b21df35d195774fbb2e9e6d663f7093362b 100644 (file)
@@ -53,7 +53,10 @@ 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, '>>', $cfg_path or BAIL_OUT $!;
@@ -69,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: {
@@ -126,9 +130,32 @@ my $es = PublicInbox::ExtSearch->new("$home/extindex");
        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
 
+       my $pi_cfg = PublicInbox::Config->new;
+       $pi_cfg->fill_all;
+       is(scalar($pi_cfg->ALL->mset('s:Testing')->items), 2,
+               '2 results in ->ALL');
+       my $res = {};
+       my $nr = 0;
+       $pi_cfg->each_inbox(sub {
+               $nr++;
+               my ($ibx) = @_;
+               local $SIG{__WARN__} = sub {}; # FIXME support --reindex
+               my $mset = $ibx->isrch->mset('s:Testing');
+               $res->{$ibx->eidx_key} = $ibx->isrch->mset_to_smsg($ibx, $mset);
+       });
+       is($nr, 2, 'two inboxes');
+       my $exp = {};
+       for my $v (qw(v1 v2)) {
+               my $ibx = $pi_cfg->lookup_newsgroup("$v.example");
+               my $smsg = $ibx->over->get_art(1);
+               $smsg->psgi_cull;
+               $exp->{"$v.example"} = [ $smsg ];
+       }
+       is_deeply($res, $exp, 'isearch limited results');
+       $pi_cfg = $res = $exp = undef;
+
        open my $rmfh, '+>', undef or BAIL_OUT $!;
        $rmfh->autoflush(1);
        print $rmfh $eml2->as_string or BAIL_OUT $!;