about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-05-07 03:00:09 +0000
committerEric Wong <e@yhbt.net>2020-05-09 00:54:34 +0000
commitb714ab45d30d6f0298d73ef4281c1d0263a02493 (patch)
treef5d3c3b64d9e04811cb372785ca950bddf301307 /t
parentc2bc9ebcb770a27823d8e989707f434826333b0e (diff)
downloadpublic-inbox-b714ab45d30d6f0298d73ef4281c1d0263a02493.tar.gz
We'll support both probabilistic matches via `l:' and boolean
matches via `lid:' for exact matches, similar to how both `m:'
and `mid:' are supported.  Only text inside angle braces (`<'
and `>') are supported, since I'm not sure if there's value in
searching on the optional phrases (which would require decoding
with ->header_str instead of ->header_raw).
Diffstat (limited to 't')
-rw-r--r--t/search.t31
1 files changed, 31 insertions, 0 deletions
diff --git a/t/search.t b/t/search.t
index 83986837..92f3305d 100644
--- a/t/search.t
+++ b/t/search.t
@@ -66,6 +66,7 @@ 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
@@ -77,6 +78,7 @@ Message-ID: <last@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
@@ -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;