]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/search.t
Merge remote-tracking branch 'origin/search'
[public-inbox.git] / t / search.t
index 201578d4cc8a8cbf124a1cddad903c856bbb8a24..9bdd3cee9964ae0ca03d1b97095a5cca3e79f52f 100644 (file)
@@ -22,7 +22,7 @@ my $ro = PublicInbox::Search->new($git_dir);
        my $root = Email::MIME->create(
                header_str => [
                        Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
-                       Subject => 'hello world',
+                       Subject => 'Hello world',
                        'Message-ID' => '<root@s>',
                        From => 'John Smith <js@example.com>',
                        To => 'list@example.com',
@@ -31,7 +31,7 @@ my $ro = PublicInbox::Search->new($git_dir);
        my $last = Email::MIME->create(
                header_str => [
                        Date => 'Sat, 02 Oct 2010 00:00:00 +0000',
-                       Subject => 'Re: hello world',
+                       Subject => 'Re: Hello world',
                        'In-Reply-To' => '<root@s>',
                        'Message-ID' => '<last@s>',
                        From => 'John Smith <js@example.com>',
@@ -48,7 +48,7 @@ my $ro = PublicInbox::Search->new($git_dir);
 
 sub filter_mids {
        my ($res) = @_;
-       sort(map { (split(/\n/, $_))[0] } @{$res->{msgs}});
+       sort(map { $_->mid } @{$res->{msgs}});
 }
 
 {
@@ -70,19 +70,19 @@ sub filter_mids {
                is($res->{count}, 0, "path variant `$p' does not match");
        }
 
-       $res = $ro->query('subject:(hello world)');
+       $res = $ro->query('subject:(Hello world)');
        @res = filter_mids($res);
        is_deeply(\@res, \@exp, 'got expected results for subject:() match');
 
-       $res = $ro->query('subject:"hello world"');
+       $res = $ro->query('subject:"Hello world"');
        @res = filter_mids($res);
        is_deeply(\@res, \@exp, 'got expected results for subject:"" match');
 
-       $res = $ro->query('subject:"hello world"', {limit => 1});
+       $res = $ro->query('subject:"Hello world"', {limit => 1});
        is(scalar @{$res->{msgs}}, 1, "limit works");
        my $first = $res->{msgs}->[0];
 
-       $res = $ro->query('subject:"hello world"', {offset => 1});
+       $res = $ro->query('subject:"Hello world"', {offset => 1});
        is(scalar @{$res->{msgs}}, 1, "offset works");
        my $second = $res->{msgs}->[0];
 
@@ -144,8 +144,7 @@ sub filter_mids {
 
        # body
        $res = $ro->query('goodbye');
-       is((split(/\n/, $res->{msgs}->[0]))[0], 'last@s',
-          'got goodbye message body');
+       is($res->{msgs}->[0]->mid, 'last@s', 'got goodbye message body');
 }
 
 # long message-id
@@ -208,7 +207,7 @@ sub filter_mids {
        $rw->add_message(Email::MIME->create(
                header_str => [
                        Date => 'Sat, 02 Oct 2010 00:00:01 +0000',
-                       Subject => 'hello',
+                       Subject => 'Hello',
                        'Message-ID' => '<quote@a>',
                        From => 'Quoter <quoter@example.com>',
                        To => 'list@example.com',
@@ -218,7 +217,7 @@ sub filter_mids {
        $rw->add_message(Email::MIME->create(
                header_str => [
                        Date => 'Sat, 02 Oct 2010 00:00:02 +0000',
-                       Subject => 'hello',
+                       Subject => 'Hello',
                        'Message-ID' => '<nquote@a>',
                        From => 'Non-Quoter<non-quoter@example.com>',
                        To => 'list@example.com',
@@ -226,12 +225,12 @@ sub filter_mids {
                body => "theatre\nfade\n"));
        my $res = $rw->query("theatre");
        is($res->{count}, 2, "got both matches");
-       like($res->{msgs}->[0], qr/\Anquote\@a/, "non-quoted scores higher");
-       like($res->{msgs}->[1], qr/\Aquote\@a/, "quoted result still returned");
+       is($res->{msgs}->[0]->mid, 'nquote@a', "non-quoted scores higher");
+       is($res->{msgs}->[1]->mid, 'quote@a', "quoted result still returned");
 
        $res = $rw->query("illusions");
        is($res->{count}, 1, "got a match for quoted text");
-       like($res->{msgs}->[0], qr/\Aquote\@a/,
+       is($res->{msgs}->[0]->mid, 'quote@a',
                "quoted result returned if nothing else");
 }