@@ -9,6 +9,7 @@ use lettre::Transport;
99use std:: net:: TcpStream ;
1010
1111use crate :: imap:: extensions:: sort:: { SortCharset , SortCriterion } ;
12+ use crate :: imap:: types:: Mailbox ;
1213
1314fn tls ( ) -> native_tls:: TlsConnector {
1415 native_tls:: TlsConnector :: builder ( )
@@ -448,3 +449,29 @@ fn append_with_flags_and_date() {
448449 let inbox = c. search ( "ALL" ) . unwrap ( ) ;
449450 assert_eq ! ( inbox. len( ) , 0 ) ;
450451}
452+
453+ #[ test]
454+ fn status ( ) {
455+ let mut s = session ( "readonly-test@localhost" ) ;
456+
457+ // Test all valid fields except HIGHESTMODSEQ, which apparently
458+ // isn't supported by the IMAP server used for this test.
459+ let mb = s. status ( "INBOX" , "(MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)" ) . unwrap ( ) ;
460+ assert_eq ! ( mb. flags, Vec :: new( ) ) ;
461+ assert_eq ! ( mb. exists, 0 ) ;
462+ assert_eq ! ( mb. recent, 0 ) ;
463+ assert ! ( mb. unseen. is_some( ) ) ;
464+ assert_eq ! ( mb. permanent_flags, Vec :: new( ) ) ;
465+ assert ! ( mb. uid_next. is_some( ) ) ;
466+ assert ! ( mb. uid_validity. is_some( ) ) ;
467+ assert_eq ! ( mb. highest_mod_seq, None ) ;
468+ assert_eq ! ( mb. is_read_only, false ) ;
469+
470+ // If we only request one field, we should only get one field
471+ // back. (A server could legally send an unsolicited STATUS
472+ // response, but this one won't.)
473+ let mb = s. status ( "INBOX" , "(MESSAGES)" ) . unwrap ( ) ;
474+ let mut expected = Mailbox :: default ( ) ;
475+ expected. exists = 0 ;
476+ assert_eq ! ( mb, expected) ;
477+ }
0 commit comments