use warnings;
use Test::More;
use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
require PublicInbox::SearchIdx;
require PublicInbox::Inbox;
require PublicInbox::InboxWritable;
Message-ID: <root@s>
From: John Smith <js@example.com>
To: list@example.com
+List-Id: I'm not mad <i.m.just.bored>
\m/
EOF
From: John Smith <js@example.com>
To: list@example.com
Cc: foo@example.com
+List-Id: there's nothing <left.for.me.to.do>
goodbye forever :<
EOF
});
$ibx->with_umask(sub {
- my $eml = 't/utf8.eml';
- my $mime = PublicInbox::InboxWritable::mime_from_path($eml) or
- die "open $eml: $!";
+ my $mime = mime_load 't/utf8.eml';
my $doc_id = $rw->add_message($mime);
ok($doc_id > 0, 'message indexed doc_id with UTF-8');
my $msg = $rw->query('m:testmessage@example.com', {limit => 1})->[0];
}
$ibx->with_umask(sub {
- my $part1 = Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- disposition => 'attachment',
- charset => 'US-ASCII',
- encoding => 'quoted-printable',
- filename => 'attached_fart.txt',
- },
- body_str => 'inside the attachment',
- );
- my $part2 = Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- disposition => 'attachment',
- charset => 'US-ASCII',
- encoding => 'quoted-printable',
- filename => 'part_deux.txt',
- },
- body_str => 'inside another',
- );
- my $amsg = Email::MIME->create(
- header_str => [
- Subject => 'see attachment',
- 'Message-ID' => '<file@attached>',
- From => 'John Smith <js@example.com>',
- To => 'list@example.com',
- ],
- parts => [ $part1, $part2 ],
- );
+ my $amsg = mime_load 't/search-amsg.eml';
ok($rw->add_message($amsg), 'added attachment');
$rw_commit->();
$ro->reopen;
is($ro->query("m:Pine m:LNX m:10010260936330", {mset=>1})->size, 1);
});
+{ # List-Id searching
+ my $found = $ro->query('lid:i.m.just.bored');
+ is_deeply([ filter_mids($found) ], [ 'root@s' ],
+ 'got expected mid on exact lid: search');
+
+ $found = $ro->query('lid:just.bored');
+ is_deeply($found, [], 'got nothing on lid: search');
+
+ $found = $ro->query('lid:*.just.bored');
+ is_deeply($found, [], 'got nothing on lid: search');
+
+ $found = $ro->query('l:i.m.just.bored');
+ is_deeply([ filter_mids($found) ], [ 'root@s' ],
+ 'probabilistic search works on full List-Id contents');
+
+ $found = $ro->query('l:just.bored');
+ is_deeply([ filter_mids($found) ], [ 'root@s' ],
+ 'probabilistic search works on partial List-Id contents');
+
+ $found = $ro->query('lid:mad');
+ is_deeply($found, [], 'no match on phrase with lid:');
+
+ $found = $ro->query('lid:bored');
+ is_deeply($found, [], 'no match on partial List-Id with lid:');
+
+ $found = $ro->query('l:nothing');
+ is_deeply($found, [], 'matched on phrase with l:');
+}
+
done_testing();
1;