]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/imapd.t
imap: reinstate non-UID SEARCH
[public-inbox.git] / t / imapd.t
index e3cce2d30f07ee9aa4339e93b475a2a33a755a40..36082d8c7eea187f4166c2b99397338e8980775c 100644 (file)
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -8,7 +8,8 @@ use Time::HiRes ();
 use PublicInbox::TestCommon;
 use PublicInbox::Config;
 use PublicInbox::Spawn qw(which);
-require_mods(qw(DBD::SQLite Mail::IMAPClient Mail::IMAPClient::BodyStructure));
+require_mods(qw(DBD::SQLite Mail::IMAPClient Mail::IMAPClient::BodyStructure
+       Email::Address::XS||Mail::Address));
 my $imap_client = 'Mail::IMAPClient';
 my $can_compress = $imap_client->can('compress');
 if ($can_compress) { # hope this gets fixed upstream, soon
@@ -147,10 +148,16 @@ is_deeply(scalar $mic->flags('1'), [], '->flags works');
        my $exp = $mic->fetch_hash(1, 'UID');
        $ret = $mic->fetch_hash('559:*', 'UID');
        is_deeply($ret, $exp, 'beginning range too big');
-       for my $r (qw(559:558 558:559)) {
-               $ret = $mic->fetch_hash($r, 'UID');
+       {
+               my @w; # Mail::IMAPClient hits a warning via overload
+               local $SIG{__WARN__} = sub { push @w, @_ };
+               $ret = $mic->fetch_hash(my $r = '559:558', 'UID');
                is_deeply($ret, {}, "out-of-range UID FETCH $r");
+               @w = grep(!/\boverload\.pm\b/, @w);
+               is_deeply(\@w, [], 'no unexpected warning');
        }
+       $ret = $mic->fetch_hash(my $r = '558:559', 'UID');
+       is_deeply($ret, {}, "out-of-range UID FETCH $r");
 }
 
 for my $r ('1:*', '1') {
@@ -216,8 +223,8 @@ for my $r ('1:*', '1') {
        is(lc($bs->bodytype), 'text', '->bodytype');
        is(lc($bs->bodyenc), '8bit', '->bodyenc');
 }
-
-is_deeply([$mic->has_capability('COMPRESS')], ['DEFLATE'], 'deflate cap');
+ok($mic->has_capability('COMPRESS') ||
+       $mic->has_capability('COMPRESS=DEFLATE'), 'deflate cap');
 SKIP: {
        skip 'Mail::IMAPClient too old for ->compress', 2 if !$can_compress;
        my $c = $imap_client->new(%mic_opt);
@@ -242,7 +249,7 @@ $pi_config->each_inbox(sub {
        my $mb = "$ng.$first_range";
        my $uidnext = $mic->uidnext($mb); # we'll fetch BODYSTRUCTURE on this
        ok($uidnext, 'got uidnext for later fetch');
-       is_deeply([$mic->has_capability('IDLE')], ['IDLE'], "IDLE capa $name");
+       ok($mic->has_capability('IDLE'), "IDLE capa $name");
        ok(!$mic->idle, "IDLE fails w/o SELECT/EXAMINE $name");
        ok($mic->examine($mb), "EXAMINE $ng succeeds");
        ok(my $idle_tag = $mic->idle, "IDLE succeeds on $ng");
@@ -387,10 +394,11 @@ SKIP: {
        is($x, $ret->{2}->{RFC822}, 'message 2 unchanged');
 }
 
+# FIXME? no EXPUNGE response, yet
 my $r2 = $mic->fetch_hash('1:*', 'BODY.PEEK[]') or BAIL_OUT "FETCH $@";
 is(scalar keys %$r2, 2, 'did not get all 3 messages');
-is($r2->{1}->{'BODY[]'}, $ret->{2}->{RFC822}, 'message 2 unchanged');
-is($r2->{2}->{'BODY[]'}, $ret->{3}->{RFC822}, 'message 3 unchanged');
+is($r2->{2}->{'BODY[]'}, $ret->{2}->{RFC822}, 'message 2 unchanged');
+is($r2->{3}->{'BODY[]'}, $ret->{3}->{RFC822}, 'message 3 unchanged');
 $r2 = $mic->fetch_hash(2, 'BODY.PEEK[HEADER.FIELDS (message-id)]')
                        or BAIL_OUT "FETCH $@";
 is($r2->{2}->{'BODY[HEADER.FIELDS (MESSAGE-ID)]'},
@@ -405,7 +413,9 @@ is($r2->{2}->{'BODY[HEADER.FIELDS (MESSAGE-ID)]'},
        pop @new_list;
        pop @orig_list;
        # TODO: not sure if sort order matters, imapd_refresh_finalize
-       # sorts, for now, but maybe clients don't care...
+       # doesn't sort, hopefully clients don't care...
+       @new_list = sort @new_list;
+       @orig_list = sort @orig_list;
        is_deeply(\@new_list, \@orig_list, 'LIST identical');
 }
 ok($mic->close, 'CLOSE works');