1 # Copyright (C) 2017 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use File::Temp qw/tempdir/;
8 eval { require PublicInbox::SearchIdx; };
9 plan skip_all => "Xapian missing for search" if $@;
10 my $tmpdir = tempdir('pi-search-thr-index.XXXXXX', TMPDIR => 1, CLEANUP => 1);
11 my $git_dir = "$tmpdir/a.git";
13 is(0, system(qw(git init -q --bare), $git_dir), "git init (main)");
14 my $rw = PublicInbox::SearchIdx->new($git_dir, 1);
15 ok($rw, "search indexer created");
33 # nb. using internal API, fragile!
34 my $xdb = $rw->_xdb_acquire;
35 $xdb->begin_transaction;
38 foreach (reverse split(/\n\n/, $data)) {
40 my $mime = Email::MIME->new(\$_);
41 $mime->header_set('From' => 'bw@g');
42 $mime->header_set('To' => 'git@vger.kernel.org');
43 my $bytes = bytes::length($mime->as_string);
44 my $doc_id = $rw->add_message($mime, $bytes, ++$num, 'ignored');
45 my $mid = $mime->header('Message-Id');
47 ok($doc_id, 'message added: '. $mid);
51 foreach my $mid (@mids) {
52 my $res = $rw->get_thread($mid);
53 is(3, $res->{total}, "got all messages from $mid");