github.com/cloudfoundry-incubator/stembuild@v0.0.0-20211223202937-5b61d62226c6/commandparser/construct_messenger_test.go (about)

     1  package commandparser_test
     2  
     3  import (
     4  	"errors"
     5  	"github.com/cloudfoundry-incubator/stembuild/commandparser"
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  	. "github.com/onsi/gomega/gbytes"
     9  )
    10  
    11  var _ = Describe("ConstructMessenger", func() {
    12  	var (
    13  		cm commandparser.ConstructCmdMessenger
    14  		g  *Buffer
    15  	)
    16  
    17  	BeforeEach(func() {
    18  		g = NewBuffer()
    19  		cm = commandparser.ConstructCmdMessenger{OutputChannel: g}
    20  	})
    21  
    22  	Describe("ArgumentsNotProvided", func() {
    23  		It("should output an appropriate error", func() {
    24  			cm.ArgumentsNotProvided()
    25  			Eventually(g).Should(Say("Not all required parameters were provided. See stembuild --help for more details"))
    26  		})
    27  	})
    28  
    29  	Describe("LGPONotFound", func() {
    30  		It("should output an appropriate error", func() {
    31  			cm.LGPONotFound()
    32  			Eventually(g).Should(Say("Could not find LGPO.zip in the current directory"))
    33  		})
    34  	})
    35  
    36  	Describe("CannotConnectToVM", func() {
    37  		It("should output an appropriate error", func() {
    38  			connectionError := errors.New("some connection error")
    39  			cm.CannotConnectToVM(connectionError)
    40  			Eventually(g).Should(Say("Cannot connect to VM: %s", connectionError))
    41  		})
    42  	})
    43  
    44  	Describe("CannotPrepareVM", func() {
    45  		It("should output an appropriate error", func() {
    46  			preparationError := errors.New("PrepareVM failed")
    47  			cm.CannotPrepareVM(preparationError)
    48  			Eventually(g).Should(Say("Could not prepare VM: %s", preparationError))
    49  		})
    50  	})
    51  })