From 327bc0c1230b1bcb468ba4d5ac2fbfda26c27b99 Mon Sep 17 00:00:00 2001 From: Michael Chinigo Date: Mon, 19 Aug 2024 17:49:37 -0400 Subject: [PATCH 1/6] Support the --no-wait flag for `cf continue-deployment` --- command/v7/continue_deployment_command.go | 5 ++- .../v7/continue_deployment_command_test.go | 37 ++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) 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..425ce8a9ac2 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 ) @@ -67,6 +68,7 @@ var _ = Describe("Continue deployment command", func() { }) JustBeforeEach(func() { + cmd.NoWait = noWait executeErr = cmd.Execute(nil) }) @@ -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,36 @@ var _ = Describe("Continue deployment command", func() { Expect(executeErr).ToNot(HaveOccurred()) }) + When("the --no-wait flag is not provided", func() { + BeforeEach(func() { + noWait = false + }) + + It("polls and waits", func() { + Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) + + var 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() { + noWait = true + }) + + It("polls without waiting", func() { + Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) + + var 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( From 6bd04fc4cf924e7da91519749800912ec8784bbd Mon Sep 17 00:00:00 2001 From: Michael Chinigo Date: Tue, 20 Aug 2024 11:38:03 -0400 Subject: [PATCH 2/6] Update assertion on `cf continue-deployment` help text --- .../v7/isolated/continue_deployment_test.go | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/integration/v7/isolated/continue_deployment_test.go b/integration/v7/isolated/continue_deployment_test.go index 4c1bf73370e..a490c7744c7 100644 --- a/integration/v7/isolated/continue_deployment_test.go +++ b/integration/v7/isolated/continue_deployment_test.go @@ -23,22 +23,21 @@ var _ = Describe("Continue Deployment", func() { It("displays the help information", func() { session := helpers.CF("continue-deployment", "--help") - Eventually(session).Should(Say(`NAME:`)) - Eventually(session).Should(Say(`continue-deployment - Continue the most recent deployment for an app.\n`)) - Eventually(session).Should(Say(`\n`)) - Eventually(session).Should(Say(`USAGE:`)) - Eventually(session).Should(Say(`cf continue-deployment APP_NAME\n`)) - Eventually(session).Should(Say(`\n`)) + Eventually(session).Should(Say(`NAME: + continue-deployment - Continue the most recent deployment for an app. - Eventually(session).Should(Say(`EXAMPLES:`)) - Eventually(session).Should(Say(`cf continue-deployment my-app\n`)) - Eventually(session).Should(Say(`\n`)) +USAGE: + cf continue-deployment APP_NAME [--no-wait] - Eventually(session).Should(Say(`SEE ALSO:`)) - Eventually(session).Should(Say(`app, push`)) +EXAMPLES: + cf continue-deployment my-app - Eventually(session).Should(Exit(0)) +OPTIONS: + --no-wait Exit when the first instance of the web process is healthy + +SEE ALSO: + app, push`)) }) }) From 6ff7c85b14f618ed0347e8296b4e523ffbda4976 Mon Sep 17 00:00:00 2001 From: Michael Chinigo Date: Tue, 20 Aug 2024 11:40:59 -0400 Subject: [PATCH 3/6] Remove `var` keyword per PR feedback --- command/v7/continue_deployment_command_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/command/v7/continue_deployment_command_test.go b/command/v7/continue_deployment_command_test.go index 425ce8a9ac2..ff192056f9b 100644 --- a/command/v7/continue_deployment_command_test.go +++ b/command/v7/continue_deployment_command_test.go @@ -215,7 +215,7 @@ var _ = Describe("Continue deployment command", func() { It("polls and waits", func() { Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) - var invokedApplication, invokedGuid, invokedNoWait, _ = fakeActor.PollStartForDeploymentArgsForCall(0) + invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0) Expect(invokedApplication).To(Equal(returnedApplication)) Expect(invokedGuid).To(Equal(deploymentGUID)) Expect(invokedNoWait).To(Equal(false)) @@ -230,7 +230,7 @@ var _ = Describe("Continue deployment command", func() { It("polls without waiting", func() { Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) - var invokedApplication, invokedGuid, invokedNoWait, _ = fakeActor.PollStartForDeploymentArgsForCall(0) + invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0) Expect(invokedApplication).To(Equal(returnedApplication)) Expect(invokedGuid).To(Equal(deploymentGUID)) Expect(invokedNoWait).To(Equal(true)) From f32744070145da3414426f11316312715835c194 Mon Sep 17 00:00:00 2001 From: Michael Chinigo Date: Tue, 20 Aug 2024 15:38:10 -0400 Subject: [PATCH 4/6] Revert "Update assertion on `cf continue-deployment` help text" This reverts commit bf7933cf17a7d25c27f37e8f8a3b9b5fb210654a. --- .../v7/isolated/continue_deployment_test.go | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/integration/v7/isolated/continue_deployment_test.go b/integration/v7/isolated/continue_deployment_test.go index a490c7744c7..4c1bf73370e 100644 --- a/integration/v7/isolated/continue_deployment_test.go +++ b/integration/v7/isolated/continue_deployment_test.go @@ -23,21 +23,22 @@ var _ = Describe("Continue Deployment", func() { It("displays the help information", func() { session := helpers.CF("continue-deployment", "--help") + Eventually(session).Should(Say(`NAME:`)) + Eventually(session).Should(Say(`continue-deployment - Continue the most recent deployment for an app.\n`)) + Eventually(session).Should(Say(`\n`)) - Eventually(session).Should(Say(`NAME: - continue-deployment - Continue the most recent deployment for an app. + Eventually(session).Should(Say(`USAGE:`)) + Eventually(session).Should(Say(`cf continue-deployment APP_NAME\n`)) + Eventually(session).Should(Say(`\n`)) -USAGE: - cf continue-deployment APP_NAME [--no-wait] + Eventually(session).Should(Say(`EXAMPLES:`)) + Eventually(session).Should(Say(`cf continue-deployment my-app\n`)) + Eventually(session).Should(Say(`\n`)) -EXAMPLES: - cf continue-deployment my-app + Eventually(session).Should(Say(`SEE ALSO:`)) + Eventually(session).Should(Say(`app, push`)) -OPTIONS: - --no-wait Exit when the first instance of the web process is healthy - -SEE ALSO: - app, push`)) + Eventually(session).Should(Exit(0)) }) }) From b1f058396fb4f05b0d8f4614801bc1f8f8674bce Mon Sep 17 00:00:00 2001 From: Michael Chinigo Date: Tue, 20 Aug 2024 15:45:23 -0400 Subject: [PATCH 5/6] Fix assertion about `cf continue-deployment` help text --- integration/v7/isolated/continue_deployment_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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`)) From 7b2b2907585a3a0e54dd8b8f890f09526e213ddf Mon Sep 17 00:00:00 2001 From: Michael Chinigo Date: Tue, 20 Aug 2024 15:53:34 -0400 Subject: [PATCH 6/6] Change `continue-deployment` unit test to match style of similar tests --- command/v7/continue_deployment_command_test.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/command/v7/continue_deployment_command_test.go b/command/v7/continue_deployment_command_test.go index ff192056f9b..66ce4535f91 100644 --- a/command/v7/continue_deployment_command_test.go +++ b/command/v7/continue_deployment_command_test.go @@ -45,6 +45,7 @@ var _ = Describe("Continue deployment command", func() { cmd = ContinueDeploymentCommand{ RequiredArgs: flag.AppName{AppName: appName}, + NoWait: noWait, BaseCommand: BaseCommand{ UI: testUI, Config: fakeConfig, @@ -68,7 +69,6 @@ var _ = Describe("Continue deployment command", func() { }) JustBeforeEach(func() { - cmd.NoWait = noWait executeErr = cmd.Execute(nil) }) @@ -208,10 +208,6 @@ var _ = Describe("Continue deployment command", func() { }) When("the --no-wait flag is not provided", func() { - BeforeEach(func() { - noWait = false - }) - It("polls and waits", func() { Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) @@ -224,7 +220,7 @@ var _ = Describe("Continue deployment command", func() { When("the --no-wait flag is provided", func() { BeforeEach(func() { - noWait = true + cmd.NoWait = true }) It("polls without waiting", func() {