github.com/jordwest/imap-server@v0.0.0-20200627020849-1cf758ba359f/conn/command_status_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("STATUS 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 respond with the status of INBOX", func() {
    16  			SendLine("abcd.123 STATUS INBOX (UIDNEXT UNSEEN)")
    17  			ExpectResponse("* STATUS INBOX (UIDNEXT 13 UNSEEN 3)")
    18  			ExpectResponse("abcd.123 OK STATUS Completed")
    19  		})
    20  	})
    21  
    22  	Context("When not logged in", func() {
    23  		BeforeEach(func() {
    24  			tConn.SetState(conn.StateNotAuthenticated)
    25  		})
    26  
    27  		It("should give an error", func() {
    28  			SendLine("abcd.123 STATUS INBOX (UIDNEXT UNSEEN)")
    29  			ExpectResponse("abcd.123 BAD not authenticated")
    30  		})
    31  	})
    32  })