github.com/jordwest/imap-server@v0.0.0-20200627020849-1cf758ba359f/conn/command_select_test.go (about)

     1  package conn_test
     2  
     3  import (
     4  	"github.com/jordwest/imap-server/conn"
     5  	. "github.com/onsi/ginkgo"
     6  )
     7  
     8  var _ = Describe("SELECT Command", func() {
     9  	Context("When logged in", func() {
    10  		BeforeEach(func() {
    11  			tConn.SetState(conn.StateAuthenticated)
    12  			tConn.User = mStore.User
    13  		})
    14  
    15  		It("should select the INBOX mailbox", func() {
    16  			SendLine("abcd.123 SELECT INBOX")
    17  			ExpectResponse("* 3 EXISTS")
    18  			ExpectResponse("* 3 RECENT")
    19  			ExpectResponse("* OK [UNSEEN 3]")
    20  			ExpectResponse("* OK [UIDNEXT 13]")
    21  			ExpectResponse("* OK [UIDVALIDITY 250]")
    22  			ExpectResponse("* FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)")
    23  		})
    24  	})
    25  
    26  	Context("When not logged in", func() {
    27  		BeforeEach(func() {
    28  			tConn.SetState(conn.StateNotAuthenticated)
    29  		})
    30  
    31  		It("should give an error", func() {
    32  			SendLine("abcd.123 SELECT INBOX")
    33  			ExpectResponse("abcd.123 BAD not authenticated")
    34  		})
    35  	})
    36  })