github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v7/push/buildpacks_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("buildpacks", func() { 12 var ( 13 appName string 14 ) 15 16 BeforeEach(func() { 17 appName = helpers.PrefixedRandomName("app") 18 }) 19 20 When("the -b flag is provided", func() { 21 When("an existing application has a buildpack set", func() { 22 BeforeEach(func() { 23 helpers.WithHelloWorldApp(func(appDir string) { 24 Eventually( 25 helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 26 PushCommandName, appName, 27 "-b", "java_buildpack"), 28 ).Should(Exit(1)) 29 }) 30 }) 31 32 When("resetting the buildpack to autodetection", func() { 33 It("successfully pushes the app with -b default", func() { 34 helpers.WithHelloWorldApp(func(appDir string) { 35 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 36 PushCommandName, appName, 37 "-b", "default", 38 ) 39 40 Eventually(session).Should(Say(`name:\s+%s`, appName)) 41 Eventually(session).Should(Say(`requested state:\s+started`)) 42 Eventually(session).Should(Say(`buildpacks:\s+staticfile`)) 43 Eventually(session).Should(Exit(0)) 44 }) 45 }) 46 47 It("successfully pushes the app with -b null", func() { 48 helpers.WithHelloWorldApp(func(appDir string) { 49 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 50 PushCommandName, appName, 51 "-b", "null", 52 ) 53 54 Eventually(session).Should(Say(`name:\s+%s`, appName)) 55 Eventually(session).Should(Say(`requested state:\s+started`)) 56 Eventually(session).Should(Say(`buildpacks:\s+staticfile`)) 57 Eventually(session).Should(Exit(0)) 58 }) 59 }) 60 }) 61 62 When("omitting the buildpack", func() { 63 It("continues using previously set buildpack", func() { 64 helpers.WithHelloWorldApp(func(appDir string) { 65 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, PushCommandName, appName) 66 Eventually(session).Should(Say("FAILED")) 67 Eventually(session).Should(Exit(1)) 68 }) 69 }) 70 }) 71 }) 72 73 When("the buildpack is invalid", func() { 74 It("errors and does not push the app", func() { 75 helpers.WithHelloWorldApp(func(appDir string) { 76 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, PushCommandName, appName, "-b", "wut") 77 Eventually(session.Err).Should(Say(`For application '%s': Specified unknown buildpack name: "wut"`, appName)) 78 Eventually(session).Should(Say("FAILED")) 79 Eventually(session).Should(Exit(1)) 80 }) 81 }) 82 }) 83 84 When("the buildpack is valid", func() { 85 When("the buildpack already exists", func() { 86 When("pushing a single buildpack", func() { 87 It("uses the specified buildpack", func() { 88 helpers.WithHelloWorldApp(func(appDir string) { 89 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 90 PushCommandName, appName, 91 "-b", "staticfile_buildpack", 92 ) 93 94 Eventually(session).Should(Say(`name:\s+%s`, appName)) 95 Eventually(session).Should(Say(`requested state:\s+started`)) 96 Eventually(session).Should(Say(`buildpacks:\s+staticfile`)) 97 Eventually(session).Should(Exit(0)) 98 }) 99 }) 100 }) 101 102 When("pushing a multi-buildpack app", func() { 103 It("uses all the provided buildpacks in order", func() { 104 helpers.WithMultiBuildpackApp(func(appDir string) { 105 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 106 PushCommandName, appName, 107 "-b", "ruby_buildpack", 108 "-b", "go_buildpack", 109 ) 110 111 Eventually(session).Should(Say("Ruby Buildpack")) 112 Eventually(session).Should(Say("Go Buildpack")) 113 114 Eventually(session).Should(Say(`name:\s+%s`, appName)) 115 Eventually(session).Should(Say(`requested state:\s+started`)) 116 Eventually(session).Should(Say(`buildpacks:\s+ruby.*go`)) 117 Eventually(session).Should(Exit(0)) 118 }) 119 }) 120 }) 121 }) 122 123 When("the buildpack is a URL", func() { 124 It("uses the specified buildpack", func() { 125 helpers.WithHelloWorldApp(func(appDir string) { 126 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 127 PushCommandName, appName, 128 "-b", "https://github.com/cloudfoundry/staticfile-buildpack", 129 ) 130 131 Eventually(session).Should(Say(`name:\s+%s`, appName)) 132 Eventually(session).Should(Say(`requested state:\s+started`)) 133 Eventually(session).Should(Say(`buildpacks:\s+staticfile`)) 134 Eventually(session).Should(Exit(0)) 135 }) 136 }) 137 }) 138 }) 139 }) 140 })