github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/integration/isolated/update_buildpack_command_test.go (about) 1 package isolated 2 3 import ( 4 "io/ioutil" 5 "os" 6 "path/filepath" 7 8 . "code.cloudfoundry.org/cli/integration/helpers" 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("update-buildpack command", func() { 16 Context("when the buildpack is not provided", func() { 17 It("returns a buildpack argument not provided error", func() { 18 session := CF("update-buildpack", "-p", ".") 19 Eventually(session).Should(Exit(1)) 20 21 Expect(session.Err.Contents()).To(BeEquivalentTo("Incorrect Usage: the required argument `BUILDPACK` was not provided\n\n")) 22 }) 23 }) 24 25 Context("when the buildpack's path does not exist", func() { 26 It("returns a buildpack does not exist error", func() { 27 session := CF("update-buildpack", "some-buildpack", "-p", "this-is-a-bogus-path") 28 29 Eventually(session.Err).Should(Say("Incorrect Usage: The specified path 'this-is-a-bogus-path' does not exist.")) 30 Eventually(session).Should(Exit(1)) 31 }) 32 }) 33 34 Context("when the wrong data type is provided as the position argument", func() { 35 It("outputs an error message to the user, provides help text, and exits 1", func() { 36 session := CF("update-buildpack", "some-buildpack", "-i", "not-an-integer") 37 Eventually(session.Err).Should(Say("Incorrect Usage: invalid argument for flag `-i' \\(expected int\\)")) 38 Eventually(session.Out).Should(Say("cf update-buildpack BUILDPACK")) // help 39 Eventually(session).Should(Exit(1)) 40 }) 41 }) 42 43 Context("when a URL is provided as the buildpack", func() { 44 var dir string 45 46 BeforeEach(func() { 47 LoginCF() 48 49 var err error 50 dir, err = ioutil.TempDir("", "update-buildpack-test") 51 Expect(err).ToNot(HaveOccurred()) 52 53 filename := "some-file" 54 tempfile := filepath.Join(dir, filename) 55 err = ioutil.WriteFile(tempfile, []byte{}, 0400) 56 Expect(err).ToNot(HaveOccurred()) 57 58 session := CF("create-buildpack", "some-buildpack", dir, "1") 59 Eventually(session).Should(Exit(0)) 60 }) 61 62 AfterEach(func() { 63 err := os.RemoveAll(dir) 64 Expect(err).NotTo(HaveOccurred()) 65 }) 66 67 It("outputs an error message to the user, provides help text, and exits 1", func() { 68 session := CF("update-buildpack", "some-buildpack", "-p", "https://example.com/bogus.tgz") 69 Eventually(session.Out).Should(Say("Failed to create a local temporary zip file for the buildpack")) 70 Eventually(session.Out).Should(Say("FAILED")) 71 Eventually(session.Out).Should(Say("Couldn't write zip file: zip: not a valid zip file")) 72 Eventually(session).Should(Exit(1)) 73 }) 74 }) 75 })