Skip to content

Commit

Permalink
Support the --no-wait flag for cf continue-deployment [v8] (#3122)
Browse files Browse the repository at this point in the history
* Support the --no-wait flag for `cf continue-deployment`

* Update assertion on `cf continue-deployment` help text
  • Loading branch information
chinigo authored Aug 20, 2024
1 parent 20af962 commit 1661f58
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
5 changes: 3 additions & 2 deletions command/v7/continue_deployment_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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 {
Expand Down
33 changes: 32 additions & 1 deletion command/v7/continue_deployment_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var _ = Describe("Continue deployment command", func() {
fakeActor *v7fakes.FakeActor
binaryName string
appName string
noWait bool
spaceGUID string
executeErr error
)
Expand All @@ -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,
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 5 additions & 1 deletion integration/v7/isolated/continue_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`))

Expand Down

0 comments on commit 1661f58

Please sign in to comment.