github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/integration/v7/push/input_errors_test.go (about)

     1  package push
     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("input errors", func() {
    12  	var (
    13  		appName string
    14  	)
    15  
    16  	BeforeEach(func() {
    17  		appName = helpers.PrefixedRandomName("app")
    18  	})
    19  
    20  	When("the app name is not provided", func() {
    21  		It("tells the user that the app name is required, prints help text, and exits 1", func() {
    22  			session := helpers.CF(PushCommandName)
    23  
    24  			Eventually(session.Err).Should(Say("Incorrect Usage: the required argument `APP_NAME` was not provided"))
    25  			Eventually(session).Should(Say("NAME:"))
    26  			Eventually(session).Should(Exit(1))
    27  		})
    28  	})
    29  
    30  	When("the -p flag path does not exist", func() {
    31  		It("tells the user that the flag requires an arg, prints help text, and exits 1", func() {
    32  			session := helpers.CF(PushCommandName, appName, "-p", "path/that/does/not/exist")
    33  
    34  			Eventually(session.Err).Should(Say("Incorrect Usage: The specified path 'path/that/does/not/exist' does not exist."))
    35  			Eventually(session).Should(Say("NAME:"))
    36  			Eventually(session).Should(Exit(1))
    37  		})
    38  	})
    39  
    40  	Describe("argument combination errors", func() {
    41  		When("the --docker-username is provided without the -o flag", func() {
    42  			It("displays an error and exits 1", func() {
    43  				helpers.WithHelloWorldApp(func(appDir string) {
    44  					session := helpers.CF(PushCommandName, appName, "--docker-username", "some-username")
    45  					Eventually(session).Should(Say("FAILED"))
    46  					Eventually(session.Err).Should(Say("Incorrect Usage: '--docker-image, -o' and '--docker-username' must be used together."))
    47  					Eventually(session).Should(Say("NAME:"))
    48  					Eventually(session).Should(Exit(1))
    49  				})
    50  			})
    51  		})
    52  
    53  		When("the -o and -p flags are provided together", func() {
    54  			It("displays an error and exits 1", func() {
    55  				helpers.WithHelloWorldApp(func(appDir string) {
    56  					session := helpers.CF(PushCommandName, appName, "-o", PublicDockerImage, "-p", appDir)
    57  					Eventually(session).Should(Say("FAILED"))
    58  					Eventually(session.Err).Should(Say("Incorrect Usage: The following arguments cannot be used together: --docker-image, -o, --path, -p"))
    59  					Eventually(session).Should(Say("NAME:"))
    60  					Eventually(session).Should(Exit(1))
    61  				})
    62  			})
    63  		})
    64  
    65  		When("the -o and -b flags are provided together", func() {
    66  			It("displays an error and exits 1", func() {
    67  				helpers.WithHelloWorldApp(func(appDir string) {
    68  					session := helpers.CF(PushCommandName, appName, "-o", PublicDockerImage, "-b", "some-buildpack")
    69  					Eventually(session).Should(Say("FAILED"))
    70  					Eventually(session.Err).Should(Say("Incorrect Usage: The following arguments cannot be used together: --buildpack, -b, --docker-image, -o"))
    71  					Eventually(session).Should(Say("NAME:"))
    72  					Eventually(session).Should(Exit(1))
    73  				})
    74  			})
    75  		})
    76  	})
    77  })