diff options
author | Eric Wong <e@80x24.org> | 2016-09-09 00:01:22 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-09-09 00:02:16 +0000 |
commit | c617254e00ae43414236603cf9bbcdc8cbc2b139 (patch) | |
tree | c1092f94233b4532f29d288984f11738ece400c5 /t | |
parent | f9663d67d1b228b6ceaeaab8329968b0d7e445cb (diff) | |
download | public-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.t | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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; |