about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-09-09 00:01:22 +0000
committerEric Wong <e@80x24.org>2016-09-09 00:02:16 +0000
commitc617254e00ae43414236603cf9bbcdc8cbc2b139 (patch)
treec1092f94233b4532f29d288984f11738ece400c5 /t
parentf9663d67d1b228b6ceaeaab8329968b0d7e445cb (diff)
downloadpublic-inbox-c617254e00ae43414236603cf9bbcdc8cbc2b139.tar.gz
Sometimes it can be useful to search based on who the
message was sent to, sent by, or Cc:-ed.  Of course,
headers can be faked, but they usually are not...

Anyways this mostly matches the behavior of mairix(1).
Diffstat (limited to 't')
-rw-r--r--t/search.t37
1 files changed, 37 insertions, 0 deletions
diff --git a/t/search.t b/t/search.t
index db94c0a3..bb0861a1 100644
--- a/t/search.t
+++ b/t/search.t
@@ -86,6 +86,7 @@ my $rw_commit = sub {
                         'Message-ID' => '<last@s>',
                         From => 'John Smith <js@example.com>',
                         To => 'list@example.com',
+                        Cc => 'foo@example.com',
                 ],
                 body => "goodbye forever :<\n");
 
@@ -324,6 +325,42 @@ sub filter_mids {
         is(scalar @{$res->{msgs}}, 0, 'nothing before 19931001');
 }
 
+# names and addresses
+{
+        my $res = $ro->query('t:list@example.com');
+        is(scalar @{$res->{msgs}}, 6, 'searched To: successfully');
+        foreach my $smsg (@{$res->{msgs}}) {
+                like($smsg->to, qr/\blist\@example\.com\b/, 'to appears');
+        }
+
+        $res = $ro->query('tc:list@example.com');
+        is(scalar @{$res->{msgs}}, 6, 'searched To+Cc: successfully');
+        foreach my $smsg (@{$res->{msgs}}) {
+                my $tocc = join("\n", $smsg->to, $smsg->cc);
+                like($tocc, qr/\blist\@example\.com\b/, 'tocc appears');
+        }
+
+        foreach my $pfx ('tcf:', 'c:') {
+                $res = $ro->query($pfx . 'foo@example.com');
+                is(scalar @{$res->{msgs}}, 1,
+                        "searched $pfx successfully for Cc:");
+                foreach my $smsg (@{$res->{msgs}}) {
+                        like($smsg->cc, qr/\bfoo\@example\.com\b/,
+                                'cc appears');
+                }
+        }
+
+        foreach my $pfx ('', 'tcf:', 'f:') {
+                $res = $ro->query($pfx . 'Laggy');
+                is(scalar @{$res->{msgs}}, 1,
+                        "searched $pfx successfully for From:");
+                foreach my $smsg (@{$res->{msgs}}) {
+                        like($smsg->from, qr/Laggy Sender/,
+                                "From appears with $pfx");
+                }
+        }
+}
+
 done_testing();
 
 1;