github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v6/experimental/v3_cancel_zdt_push_test.go (about) 1 package experimental 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("v3-cancel-zdt-push command", func() { 12 var ( 13 orgName string 14 spaceName string 15 appName string 16 ) 17 18 BeforeEach(func() { 19 orgName = helpers.NewOrgName() 20 spaceName = helpers.NewSpaceName() 21 appName = helpers.NewAppName() 22 helpers.TurnOffExperimental() 23 }) 24 25 AfterEach(func() { 26 helpers.TurnOnExperimental() 27 }) 28 29 Describe("help", func() { 30 Context("when --help flag is set", func() { 31 It("Displays command usage to output", func() { 32 session := helpers.CF("v3-cancel-zdt-push", "--help") 33 Eventually(session).Should(Say("NAME:")) 34 Eventually(session).Should(Say("v3-cancel-zdt-push - Cancel the most recent deployment for an app")) 35 Eventually(session).Should(Say("USAGE:")) 36 Eventually(session).Should(Say("cf v3-cancel-zdt-push APP_NAME")) 37 Eventually(session).Should(Exit(0)) 38 }) 39 }) 40 }) 41 42 Context("when the environment is not setup correctly", func() { 43 It("fails with the appropriate errors", func() { 44 helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "v3-cancel-zdt-push", appName) 45 }) 46 }) 47 48 Context("when the environment is set up correctly", func() { 49 50 BeforeEach(func() { 51 helpers.SetupCF(orgName, spaceName) 52 }) 53 54 AfterEach(func() { 55 helpers.QuickDeleteOrg(orgName) 56 }) 57 58 Context("when the app name is not provided", func() { 59 It("tells the user that the app name is required, prints help text, and exits 1", func() { 60 session := helpers.CF("v3-cancel-zdt-push") 61 62 Eventually(session.Err).Should(Say("Incorrect Usage: the required argument `APP_NAME` was not provided")) 63 Eventually(session).Should(Say("NAME:")) 64 Eventually(session).Should(Exit(1)) 65 }) 66 }) 67 68 It("displays the experimental warning", func() { 69 session := helpers.CF("v3-cancel-zdt-push", appName) 70 Eventually(session.Err).Should(Say("This command is in EXPERIMENTAL stage and may change without notice")) 71 Eventually(session).Should(Exit()) 72 }) 73 74 Context("when there is no org set", func() { 75 BeforeEach(func() { 76 helpers.LogoutCF() 77 helpers.LoginCF() 78 }) 79 80 It("fails with no org targeted error message", func() { 81 session := helpers.CF("v3-cancel-zdt-push", appName) 82 Eventually(session).Should(Say("FAILED")) 83 Eventually(session.Err).Should(Say(`No org targeted, use 'cf target -o ORG' to target an org\.`)) 84 Eventually(session).Should(Exit(1)) 85 }) 86 }) 87 88 Context("when there is no space set", func() { 89 BeforeEach(func() { 90 helpers.LogoutCF() 91 helpers.LoginCF() 92 helpers.TargetOrg(ReadOnlyOrg) 93 }) 94 95 It("fails with no space targeted error message", func() { 96 session := helpers.CF("v3-cancel-zdt-push", appName) 97 Eventually(session).Should(Say("FAILED")) 98 Eventually(session.Err).Should(Say(`No space targeted, use 'cf target -s SPACE' to target a space\.`)) 99 Eventually(session).Should(Exit(1)) 100 }) 101 }) 102 103 Context("when there is no org set", func() { 104 BeforeEach(func() { 105 helpers.LogoutCF() 106 helpers.LoginCF() 107 }) 108 109 It("fails with no org targeted error message", func() { 110 session := helpers.CF("v3-cancel-zdt-push", appName) 111 Eventually(session).Should(Say("FAILED")) 112 Eventually(session.Err).Should(Say(`No org targeted, use 'cf target -o ORG' to target an org\.`)) 113 Eventually(session).Should(Exit(1)) 114 }) 115 }) 116 117 Context("when there is no space set", func() { 118 BeforeEach(func() { 119 helpers.LogoutCF() 120 helpers.LoginCF() 121 helpers.TargetOrg(ReadOnlyOrg) 122 }) 123 124 It("fails with no space targeted error message", func() { 125 session := helpers.CF("v3-cancel-zdt-push", appName) 126 Eventually(session).Should(Say("FAILED")) 127 Eventually(session.Err).Should(Say(`No space targeted, use 'cf target -s SPACE' to target a space\.`)) 128 Eventually(session).Should(Exit(1)) 129 }) 130 }) 131 132 Context("when there is no org set", func() { 133 BeforeEach(func() { 134 helpers.LogoutCF() 135 helpers.LoginCF() 136 }) 137 138 It("fails with no org targeted error message", func() { 139 session := helpers.CF("v3-cancel-zdt-push", appName) 140 Eventually(session).Should(Say("FAILED")) 141 Eventually(session.Err).Should(Say(`No org targeted, use 'cf target -o ORG' to target an org\.`)) 142 Eventually(session).Should(Exit(1)) 143 }) 144 }) 145 146 Context("when there is no space set", func() { 147 BeforeEach(func() { 148 helpers.LogoutCF() 149 helpers.LoginCF() 150 helpers.TargetOrg(ReadOnlyOrg) 151 }) 152 153 It("fails with no space targeted error message", func() { 154 session := helpers.CF("v3-cancel-zdt-push", appName) 155 Eventually(session).Should(Say("FAILED")) 156 Eventually(session.Err).Should(Say(`No space targeted, use 'cf target -s SPACE' to target a space\.`)) 157 Eventually(session).Should(Exit(1)) 158 }) 159 }) 160 161 Context("when the app exists", func() { 162 var session *Session 163 164 BeforeEach(func() { 165 helpers.WithHelloWorldApp(func(appDir string) { 166 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName) 167 Eventually(session).Should(Exit(0)) 168 }) 169 }) 170 171 Context("and it is currently deploying", func() { 172 BeforeEach(func() { 173 // zdt-push a crashing app so that underlying deployment never goes from DEPLOYING -> DEPLOYED 174 helpers.WithCrashingApp(func(appDir string) { 175 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v3-zdt-push", appName) 176 Eventually(session).Should(Exit(0)) 177 }) 178 }) 179 180 It("cancels the deployment", func() { 181 session := helpers.CF("v3-cancel-zdt-push", appName) 182 Eventually(session).Should(Exit(0)) 183 Eventually(session).Should(Say("Deployment cancelled, rolling back")) 184 }) 185 }) 186 187 Context("when the app has no deployment to cancel", func() { 188 It("errors", func() { 189 session := helpers.CF("v3-cancel-zdt-push", appName) 190 Eventually(session).Should(Exit(1)) 191 Eventually(session.Err).Should(Say("failed to find a deployment for that app")) 192 }) 193 }) 194 }) 195 }) 196 })