-# Copyright (C) 2015, all contributors <meta@public-inbox.org>
+# Copyright (C) 2015 all contributors <meta@public-inbox.org>
# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
use strict;
use warnings;
plan skip_all => "Xapian missing for search" if $@;
use File::Temp qw/tempdir/;
use Email::MIME;
-use Data::Dumper;
my $tmpdir = tempdir(CLEANUP => 1);
my $git_dir = "$tmpdir/a.git";
my ($root_id, $last_id);
my $rw = PublicInbox::SearchIdx->new($git_dir, 1);
my $ro = PublicInbox::Search->new($git_dir);
+$rw = undef;
my $rw_commit = sub {
+ $rw->{xdb}->commit_transaction if $rw;
$rw = undef;
$rw = PublicInbox::SearchIdx->new($git_dir, 1);
+ $rw->{xdb}->begin_transaction;
};
{
body => "goodbye forever :<\n");
my $rv;
+ $rw_commit->();
$root_id = $rw->add_message($root);
is($root_id, int($root_id), "root_id is an integer: $root_id");
$last_id = $rw->add_message($last);
my $second = $res->{msgs}->[0];
isnt($first, $second, "offset returned different result from limit");
-
- foreach my $f (qw(inreplyto references)) {
- $res = $ro->query($f . ':root@s');
- @res = filter_mids($res);
- is_deeply(\@res, [ 'last@s' ],
- "got expected results for $f: match");
- $res = $ro->query($f . ':root');
- is($res->{total}, 0, "no partial mid match");
- }
}
# ghost vivication
$rw_commit->();
$ro->reopen;
my $long_mid = 'last' . ('x' x 60). '@s';
- my $long_midc = Digest::SHA::sha1_hex($long_mid);
my $long = Email::MIME->create(
header_str => [
$rw_commit->();
$ro->reopen;
- my $res = $ro->query('references:root@s');
- my @res = filter_mids($res);
- is_deeply(\@res, [ sort('last@s', $long_midc) ],
- "got expected results for references: match");
-
- my $followups = $ro->get_followups('root@s');
- $followups = [ filter_mids($followups) ];
- is_deeply($followups, [ filter_mids($res) ], "get_followups matches");
+ my $res;
+ my @res;
my $long_reply_mid = 'reply-to-long@1';
my $long_reply = Email::MIME->create(
$ro->reopen;
my $t = $ro->get_thread('root@s');
is($t->{total}, 4, "got all 4 mesages in thread");
- my @exp = sort($long_reply_mid, 'root@s', 'last@s', $long_midc);
+ my @exp = sort($long_reply_mid, 'root@s', 'last@s', $long_mid);
@res = filter_mids($t);
is_deeply(\@res, \@exp, "get_thread works");
}
ok($doc_id > 0, "doc_id defined with circular reference");
my $smsg = $rw->lookup_message('circle@a');
$smsg->ensure_metadata;
- is($smsg->{references}, undef, "no references created");
+ is($smsg->references, '', "no references created");
}
done_testing();