require PublicInbox::SearchIdx;
require PublicInbox::Inbox;
require PublicInbox::InboxWritable;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
my ($tmpdir, $for_destroy) = tmpdir();
my $git_dir = "$tmpdir/a.git";
my $ibx = PublicInbox::Inbox->new({ inboxdir => $git_dir });
}
$ibx->with_umask(sub {
- my $root = PublicInbox::MIME->new(<<'EOF');
+ my $root = PublicInbox::Eml->new(<<'EOF');
Date: Fri, 02 Oct 1993 00:00:00 +0000
Subject: Hello world
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
- my $last = PublicInbox::MIME->new(<<'EOF');
+ my $last = PublicInbox::Eml->new(<<'EOF');
Date: Sat, 02 Oct 2010 00:00:00 +0000
Subject: Re: Hello world
In-Reply-To: <root@s>
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 {
$rw_commit->();
my $rmid = '<ghost-message@s>';
- my $reply_to_ghost = PublicInbox::MIME->new(<<"EOF");
+ my $reply_to_ghost = PublicInbox::Eml->new(<<"EOF");
Date: Sat, 02 Oct 2010 00:00:00 +0000
Subject: Re: ghosts
Message-ID: <ghost-reply\@s>
my $reply_id = $rw->add_message($reply_to_ghost);
is($reply_id, int($reply_id), "reply_id is an integer: $reply_id");
- my $was_ghost = PublicInbox::MIME->new(<<"EOF");
+ my $was_ghost = PublicInbox::Eml->new(<<"EOF");
Date: Sat, 02 Oct 2010 00:00:01 +0000
Subject: ghosts
Message-ID: $rmid
$rw_commit->();
$ro->reopen;
my $long_mid = 'last' . ('x' x 60). '@s';
- my $long = PublicInbox::MIME->new(<<EOF);
+ my $long = PublicInbox::Eml->new(<<EOF);
Date: Sat, 02 Oct 2010 00:00:00 +0000
Subject: long message ID
References: <root\@s> <last\@s>
my @res;
my $long_reply_mid = 'reply-to-long@1';
- my $long_reply = PublicInbox::MIME->new(<<EOF);
+ my $long_reply = PublicInbox::Eml->new(<<EOF);
Subject: I break references
Date: Sat, 02 Oct 2010 00:00:00 +0000
Message-ID: <$long_reply_mid>
# quote prioritization
$ibx->with_umask(sub {
$rw_commit->();
- $rw->add_message(PublicInbox::MIME->new(<<'EOF'));
+ $rw->add_message(PublicInbox::Eml->new(<<'EOF'));
Date: Sat, 02 Oct 2010 00:00:01 +0000
Subject: Hello
Message-ID: <quote@a>
> theatre illusions
fade
EOF
- $rw->add_message(PublicInbox::MIME->new(<<'EOF'));
+ $rw->add_message(PublicInbox::Eml->new(<<'EOF'));
Date: Sat, 02 Oct 2010 00:00:02 +0000
Subject: Hello
Message-ID: <nquote@a>
# circular references
$ibx->with_umask(sub {
my $s = 'foo://'. ('Circle' x 15).'/foo';
- my $doc_id = $rw->add_message(PublicInbox::MIME->new(<<EOF));
+ my $doc_id = $rw->add_message(PublicInbox::Eml->new(<<EOF));
Subject: $s
Date: Sat, 02 Oct 2010 00:00:01 +0000
Message-ID: <circle\@a>
});
$ibx->with_umask(sub {
- my $eml = 't/utf8.eml';
- my $mime = PublicInbox::InboxWritable::mime_from_path($eml) or
- die "open $eml: $!";
+ my $mime = eml_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 $amsg = mime_load 't/search-amsg.eml';
+ my $amsg = eml_load 't/search-amsg.eml';
ok($rw->add_message($amsg), 'added attachment');
$rw_commit->();
$ro->reopen;
my $mid = "$ua.$digits.2460-100000\@penguin.transmeta.com";
is($ro->reopen->query("m:$digits", { mset => 1})->size, 0,
'no results yet');
- my $pine = PublicInbox::MIME->new(<<EOF);
+ my $pine = PublicInbox::Eml->new(<<EOF);
Subject: blah
Message-ID: <$mid>
From: torvalds\@transmeta
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;