github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/integration/isolated/create_buildpack_command_test.go (about) 1 package isolated 2 3 import ( 4 "io/ioutil" 5 "os" 6 7 . "code.cloudfoundry.org/cli/integration/helpers" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 . "github.com/onsi/gomega/gbytes" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 var _ = Describe("create-buildpack command", func() { 15 Context("when the wrong data type is provided as the position argument", func() { 16 var filename string 17 18 BeforeEach(func() { 19 // The args take a filepath. Creating a real file will avoid the file 20 // does not exist error, and trigger the correct error case we are 21 // testing. 22 filename = "some-file" 23 err := ioutil.WriteFile(filename, []byte{}, 0400) 24 Expect(err).NotTo(HaveOccurred()) 25 }) 26 27 AfterEach(func() { 28 err := os.Remove(filename) 29 Expect(err).NotTo(HaveOccurred()) 30 }) 31 32 It("outputs an error message to the user, provides help text, and exits 1", func() { 33 session := CF("create-buildpack", "some-buildpack", "some-file", "not-an-integer") 34 Eventually(session.Err).Should(Say("Incorrect usage: Value for POSITION must be integer")) 35 Eventually(session.Out).Should(Say("cf create-buildpack BUILDPACK PATH POSITION")) // help 36 Eventually(session).Should(Exit(1)) 37 }) 38 }) 39 40 Context("when a nonexistent file is provided", func() { 41 It("outputs an error message to the user and exits 1", func() { 42 session := CF("create-buildpack", "some-buildpack", "some-bogus-file", "1") 43 Eventually(session.Err).Should(Say("Incorrect Usage: The specified path 'some-bogus-file' does not exist.")) 44 Eventually(session).Should(Exit(1)) 45 }) 46 }) 47 48 Context("when a URL is provided as the buildpack", func() { 49 BeforeEach(func() { 50 LoginCF() 51 }) 52 53 It("outputs an error message to the user, provides help text, and exits 1", func() { 54 session := CF("create-buildpack", "some-buildpack", "https://example.com/bogus.tgz", "1") 55 Eventually(session.Out).Should(Say("Failed to create a local temporary zip file for the buildpack")) 56 Eventually(session.Out).Should(Say("FAILED")) 57 Eventually(session.Out).Should(Say("Couldn't write zip file: zip: not a valid zip file")) 58 Eventually(session).Should(Exit(1)) 59 }) 60 }) 61 })