]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/search.t
www: favor reading more from SQLite, and less from Xapian
[public-inbox.git] / t / search.t
index c9bef718e42f204b574230bb0028dcfc892eaf63..fda32d36e562a815d832b9b21ad1fcf9b1ec1d9b 100644 (file)
@@ -89,10 +89,9 @@ sub filter_mids {
 {
        $rw_commit->();
        $ro->reopen;
-       my $found = $ro->first_smsg_by_mid('root@s');
-       ok($found, "message found");
-       is($root_id, $found->{doc_id}, 'doc_id set correctly');
-       is($found->mid, 'root@s', 'mid set correctly');
+       my $found = $ro->query('m:root@s');
+       is(scalar(@$found), 1, "message found");
+       is($found->[0]->mid, 'root@s', 'mid set correctly');
 
        my ($res, @res);
        my @exp = sort qw(root@s last@s);
@@ -170,6 +169,13 @@ sub filter_mids {
        # body
        $res = $ro->query('goodbye');
        is($res->[0]->mid, 'last@s', 'got goodbye message body');
+
+       # datestamp
+       $res = $ro->query('dt:20101002000001..20101002000001');
+       @res = filter_mids($res);
+       is_deeply(\@res, ['ghost-message@s'], 'exact Date: match works');
+       $res = $ro->query('dt:20101002000002..20101002000002');
+       is_deeply($res, [], 'exact Date: match down to the second');
 }
 
 # long message-id
@@ -269,10 +275,9 @@ sub filter_mids {
                ],
                body => "LOOP!\n"));
        ok($doc_id > 0, "doc_id defined with circular reference");
-       my $smsg = $rw->first_smsg_by_mid('circle@a');
+       my $smsg = $rw->query('m:circle@a', {limit=>1})->[0];
        is($smsg->references, '', "no references created");
-       my $msg = PublicInbox::SearchMsg->load_doc($smsg->{doc});
-       is($s, $msg->subject, 'long subject not rewritten');
+       is($s, $smsg->subject, 'long subject not rewritten');
 }
 
 {
@@ -286,9 +291,7 @@ sub filter_mids {
        my $mime = Email::MIME->new($str);
        my $doc_id = $rw->add_message($mime);
        ok($doc_id > 0, 'message indexed doc_id with UTF-8');
-       my $smsg = $rw->first_smsg_by_mid('testmessage@example.com');
-       my $msg = PublicInbox::SearchMsg->load_doc($smsg->{doc});
-
+       my $msg = $rw->query('m:testmessage@example.com', {limit => 1})->[0];
        is($mime->header('Subject'), $msg->subject, 'UTF-8 subject preserved');
 }