github.com/liamawhite/cli-with-i18n@v6.32.1-0.20171122084555-dede0a5c3448+incompatible/integration/push/flag_test.go (about) 1 package push 2 3 import ( 4 "io/ioutil" 5 "os" 6 7 "github.com/liamawhite/cli-with-i18n/integration/helpers" 8 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gbytes" 12 . "github.com/onsi/gomega/gexec" 13 ) 14 15 var _ = Describe("flag combinations", func() { 16 var ( 17 appName string 18 ) 19 20 BeforeEach(func() { 21 appName = helpers.NewAppName() 22 }) 23 24 Context("when the --docker-username is provided without an image", func() { 25 It("errors with usage", func() { 26 session := helpers.CF(PushCommandName, "--docker-username", "some-docker-username", appName) 27 Eventually(session.Err).Should(Say("Incorrect Usage: '--docker-image, -o' and '--docker-username' must be used together.")) 28 Eventually(session).Should(Say("NAME:")) 29 Eventually(session).Should(Say("Push a new app or sync changes to an existing app")) 30 Eventually(session).Should(Exit(1)) 31 }) 32 }) 33 34 Context("when CF_DOCKER_PASSWORD is *not* set", func() { 35 It("errors with usage", func() { 36 session := helpers.CF(PushCommandName, "--docker-username", "some-docker-username", "--docker-image", "some-docker-image", appName) 37 Eventually(session.Err).Should(Say("Environment variable CF_DOCKER_PASSWORD not set.")) 38 Eventually(session).Should(Exit(1)) 39 }) 40 }) 41 42 Context("when the -p and -o flags are used together", func() { 43 var path string 44 45 BeforeEach(func() { 46 tempFile, err := ioutil.TempFile("", "integration-push-path") 47 Expect(err).ToNot(HaveOccurred()) 48 path = tempFile.Name() 49 Expect(tempFile.Close()) 50 }) 51 52 AfterEach(func() { 53 err := os.Remove(path) 54 Expect(err).ToNot(HaveOccurred()) 55 }) 56 57 It("tells the user that they cannot be used together, displays usage and fails", func() { 58 session := helpers.CF(PushCommandName, appName, "-o", PublicDockerImage, "-p", path) 59 60 Eventually(session.Err).Should(Say("Incorrect Usage: The following arguments cannot be used together: --docker-image, -o, -p")) 61 Eventually(session).Should(Say("FAILED")) 62 Eventually(session).Should(Say("USAGE:")) 63 64 Eventually(session).Should(Exit(1)) 65 }) 66 }) 67 68 Context("when the -b and -o flags are used together", func() { 69 It("tells the user that they cannot be used together, displays usage and fails", func() { 70 session := helpers.CF(PushCommandName, appName, "-o", PublicDockerImage, "-b", "some-buildpack") 71 72 Consistently(session.Out).ShouldNot(Say("Creating app")) 73 Eventually(session.Err).Should(Say("Incorrect Usage: The following arguments cannot be used together: -b, --docker-image, -o")) 74 Eventually(session).Should(Say("FAILED")) 75 Eventually(session).Should(Say("USAGE:")) 76 77 Eventually(session).Should(Exit(1)) 78 }) 79 }) 80 })