github.com/sleungcy-sap/cli@v7.1.0+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 -p flag path does not exist", func() { 21 It("tells the user that the flag requires an arg, prints help text, and exits 1", func() { 22 session := helpers.CF(PushCommandName, appName, "-p", "path/that/does/not/exist") 23 24 Eventually(session.Err).Should(Say("Incorrect Usage: The specified path 'path/that/does/not/exist' does not exist.")) 25 Eventually(session).Should(Say("NAME:")) 26 Eventually(session).Should(Exit(1)) 27 }) 28 }) 29 30 Describe("argument combination errors", func() { 31 When("the --docker-username is provided without the -o flag", func() { 32 It("displays an error and exits 1", func() { 33 helpers.WithHelloWorldApp(func(appDir string) { 34 session := helpers.CF(PushCommandName, appName, "--docker-username", "some-username") 35 Eventually(session).Should(Say("FAILED")) 36 Eventually(session.Err).Should(Say("Incorrect Usage: '--docker-image, -o' and '--docker-username' must be used together.")) 37 Eventually(session).Should(Say("NAME:")) 38 Eventually(session).Should(Exit(1)) 39 }) 40 }) 41 }) 42 43 When("the -o and -p flags are provided together", func() { 44 It("displays an error and exits 1", func() { 45 helpers.WithHelloWorldApp(func(appDir string) { 46 session := helpers.CF(PushCommandName, appName, "-o", PublicDockerImage, "-p", appDir) 47 Eventually(session).Should(Say("FAILED")) 48 Eventually(session.Err).Should(Say("Incorrect Usage: The following arguments cannot be used together: --docker-image, -o, --path, -p")) 49 Eventually(session).Should(Say("NAME:")) 50 Eventually(session).Should(Exit(1)) 51 }) 52 }) 53 }) 54 55 When("the -o and -b flags are provided together", func() { 56 It("displays an error and exits 1", func() { 57 helpers.WithHelloWorldApp(func(appDir string) { 58 session := helpers.CF(PushCommandName, appName, "-o", PublicDockerImage, "-b", "some-buildpack") 59 Eventually(session).Should(Say("FAILED")) 60 Eventually(session.Err).Should(Say("Incorrect Usage: The following arguments cannot be used together: --buildpack, -b, --docker-image, -o")) 61 Eventually(session).Should(Say("NAME:")) 62 Eventually(session).Should(Exit(1)) 63 }) 64 }) 65 }) 66 }) 67 })