github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/integration/isolated/curl_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/integration/helpers"
     5  	. "github.com/onsi/ginkgo"
     6  	. "github.com/onsi/gomega"
     7  	. "github.com/onsi/gomega/gbytes"
     8  	. "github.com/onsi/gomega/gexec"
     9  )
    10  
    11  var _ = Describe("error handling", func() {
    12  	Describe("exit codes", func() {
    13  		Context("when an unknown command is invoked", func() {
    14  			It("exits 1", func() {
    15  				session := helpers.CF("some-command-that-should-never-actually-be-a-real-thing-i-can-use")
    16  
    17  				Eventually(session).Should(Exit(1))
    18  				Eventually(session).Should(Say("not a registered command"))
    19  			})
    20  		})
    21  
    22  		Context("when a known command is invoked with an invalid option", func() {
    23  			It("exits 1", func() {
    24  				session := helpers.CF("push", "--crazy")
    25  
    26  				Eventually(session).Should(Exit(1))
    27  			})
    28  		})
    29  	})
    30  
    31  	Describe("incorrect usage", func() {
    32  		Context("when a command is invoked with an invalid options", func() {
    33  			It("does not display requirement errors twice", func() {
    34  				session := helpers.CF("space")
    35  
    36  				Eventually(session.Err).Should(Say("the required argument `SPACE` was not provided"))
    37  				Consistently(session.Err).ShouldNot(Say("the required argument `SPACE` was not provided"))
    38  				Consistently(session.Out).ShouldNot(Say("the required argument `SPACE` was not provided"))
    39  				Eventually(session).Should(Exit(1))
    40  			})
    41  		})
    42  	})
    43  })