diff --git a/command/v7/continue_deployment_command.go b/command/v7/continue_deployment_command.go index cfd5530080e..135cdbe978a 100644 --- a/command/v7/continue_deployment_command.go +++ b/command/v7/continue_deployment_command.go @@ -9,7 +9,8 @@ type ContinueDeploymentCommand struct { BaseCommand RequiredArgs flag.AppName `positional-args:"yes"` - usage interface{} `usage:"CF_NAME continue-deployment APP_NAME\n\nEXAMPLES:\n cf continue-deployment my-app"` + NoWait bool `long:"no-wait" description:"Exit when the first instance of the web process is healthy"` + usage interface{} `usage:"CF_NAME continue-deployment APP_NAME [--no-wait]\n\nEXAMPLES:\n cf continue-deployment my-app"` relatedCommands interface{} `related_commands:"app, push"` } @@ -58,7 +59,7 @@ func (cmd *ContinueDeploymentCommand) Execute(args []string) error { cmd.UI.DisplayText(instanceDetails) } - warnings, err = cmd.Actor.PollStartForDeployment(application, deployment.GUID, false, handleInstanceDetails) + warnings, err = cmd.Actor.PollStartForDeployment(application, deployment.GUID, cmd.NoWait, handleInstanceDetails) cmd.UI.DisplayNewline() cmd.UI.DisplayWarnings(warnings) if err != nil { diff --git a/command/v7/continue_deployment_command_test.go b/command/v7/continue_deployment_command_test.go index a5086c5c9bb..66ce4535f91 100644 --- a/command/v7/continue_deployment_command_test.go +++ b/command/v7/continue_deployment_command_test.go @@ -28,6 +28,7 @@ var _ = Describe("Continue deployment command", func() { fakeActor *v7fakes.FakeActor binaryName string appName string + noWait bool spaceGUID string executeErr error ) @@ -44,6 +45,7 @@ var _ = Describe("Continue deployment command", func() { cmd = ContinueDeploymentCommand{ RequiredArgs: flag.AppName{AppName: appName}, + NoWait: noWait, BaseCommand: BaseCommand{ UI: testUI, Config: fakeConfig, @@ -126,10 +128,13 @@ var _ = Describe("Continue deployment command", func() { When("getting the app succeeds", func() { var appGUID string + var returnedApplication resources.Application + BeforeEach(func() { appGUID = "some-app-guid" + returnedApplication = resources.Application{Name: appName, GUID: appGUID} fakeActor.GetApplicationByNameAndSpaceReturns( - resources.Application{Name: appName, GUID: appGUID}, + returnedApplication, v7action.Warnings{"get-app-warning"}, nil, ) @@ -202,6 +207,32 @@ var _ = Describe("Continue deployment command", func() { Expect(executeErr).ToNot(HaveOccurred()) }) + When("the --no-wait flag is not provided", func() { + It("polls and waits", func() { + Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) + + invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0) + Expect(invokedApplication).To(Equal(returnedApplication)) + Expect(invokedGuid).To(Equal(deploymentGUID)) + Expect(invokedNoWait).To(Equal(false)) + }) + }) + + When("the --no-wait flag is provided", func() { + BeforeEach(func() { + cmd.NoWait = true + }) + + It("polls without waiting", func() { + Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) + + invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0) + Expect(invokedApplication).To(Equal(returnedApplication)) + Expect(invokedGuid).To(Equal(deploymentGUID)) + Expect(invokedNoWait).To(Equal(true)) + }) + }) + When("polling the application fails", func() { BeforeEach(func() { fakeActor.PollStartForDeploymentReturns( diff --git a/integration/v7/isolated/continue_deployment_test.go b/integration/v7/isolated/continue_deployment_test.go index 4c1bf73370e..29f0362363a 100644 --- a/integration/v7/isolated/continue_deployment_test.go +++ b/integration/v7/isolated/continue_deployment_test.go @@ -28,13 +28,17 @@ var _ = Describe("Continue Deployment", func() { Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`USAGE:`)) - Eventually(session).Should(Say(`cf continue-deployment APP_NAME\n`)) + Eventually(session).Should(Say(`cf continue-deployment APP_NAME \[--no-wait\]\n`)) Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`EXAMPLES:`)) Eventually(session).Should(Say(`cf continue-deployment my-app\n`)) Eventually(session).Should(Say(`\n`)) + Eventually(session).Should(Say(`OPTIONS:`)) + Eventually(session).Should(Say(`--no-wait\s+Exit when the first instance of the web process is healthy`)) + Eventually(session).Should(Say(`\n`)) + Eventually(session).Should(Say(`SEE ALSO:`)) Eventually(session).Should(Say(`app, push`))