X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fsearch.t;h=6dd5047454aa48336895d72d843e22da8ec3ae38;hb=0283273a14e1871955f6a9132f4f3f7884ec8a3f;hp=83986837eaf9190e8c98aa21115dfeb2db19c38a;hpb=aa454143b1f26ffdf5f32f17c2032473d70eceae;p=public-inbox.git diff --git a/t/search.t b/t/search.t index 83986837..6dd50474 100644 --- a/t/search.t +++ b/t/search.t @@ -8,7 +8,7 @@ require_mods(qw(DBD::SQLite Search::Xapian)); 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 }); @@ -60,16 +60,17 @@ sub oct_is ($$$) { } $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: From: John Smith To: list@example.com +List-Id: I'm not mad \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: @@ -77,6 +78,7 @@ Message-ID: From: John Smith To: list@example.com Cc: foo@example.com +List-Id: there's nothing goodbye forever :< EOF @@ -126,7 +128,7 @@ sub filter_mids { $ibx->with_umask(sub { $rw_commit->(); my $rmid = ''; - 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: @@ -140,7 +142,7 @@ EOF 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 @@ -189,7 +191,7 @@ $ibx->with_umask(sub { $rw_commit->(); $ro->reopen; my $long_mid = 'last' . ('x' x 60). '@s'; - my $long = PublicInbox::MIME->new(<new(< @@ -209,7 +211,7 @@ EOF my @res; my $long_reply_mid = 'reply-to-long@1'; - my $long_reply = PublicInbox::MIME->new(<new(< @@ -233,7 +235,7 @@ EOF # 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: @@ -243,7 +245,7 @@ To: list@example.com > 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: @@ -267,7 +269,7 @@ EOF # circular references $ibx->with_umask(sub { my $s = 'foo://'. ('Circle' x 15).'/foo'; - my $doc_id = $rw->add_message(PublicInbox::MIME->new(<add_message(PublicInbox::Eml->new(< @@ -286,7 +288,7 @@ EOF }); $ibx->with_umask(sub { - my $mime = mime_load 't/utf8.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]; @@ -369,7 +371,7 @@ $ibx->with_umask(sub { } $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; @@ -427,7 +429,7 @@ $ibx->with_umask(sub { 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(<new(< From: torvalds\@transmeta @@ -448,6 +450,35 @@ EOF 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;