]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/extsearch.t
t/extsearch: use indexlevel=basic in inboxes
[public-inbox.git] / t / extsearch.t
index 2b8b88ea2697ff104e0a8495d480545caad2c5fb..965122278e56a777ac31548fb661b7e7ac984abd 100644 (file)
@@ -25,8 +25,8 @@ EOF
 close $fh or BAIL_OUT $!;
 my $v2addr = 'v2test@example.com';
 my $v1addr = 'v1test@example.com';
-ok(run_script([qw(-init -V2 v2test --newsgroup v2.example), "$home/v2test",
-       'http://example.com/v2test', $v2addr ]), 'v2test init');
+ok(run_script([qw(-init -Lbasic -V2 v2test --newsgroup v2.example),
+       "$home/v2test", 'http://example.com/v2test', $v2addr ]), 'v2test init');
 my $env = { ORIGINAL_RECIPIENT => $v2addr };
 my $eml = eml_load('t/utf8.eml');
 
@@ -50,7 +50,7 @@ seek($fh, 0, SEEK_SET) or BAIL_OUT $!;
 $env = { ORIGINAL_RECIPIENT => $v1addr };
 run_script(['-mda', '--no-precheck'], $env, { 0 => $fh }) or BAIL_OUT '-mda';
 
-run_script(['-index', "$home/v1test"]) or BAIL_OUT "index $?";
+run_script([qw(-index -Lbasic), "$home/v1test"]) or BAIL_OUT "index $?";
 
 ok(run_script([qw(-extindex --all), "$home/extindex"]), 'extindex init');
 {
@@ -130,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 $!;