Skip to content

Commit

Permalink
Return error when no app/revision is present
Browse files Browse the repository at this point in the history
  • Loading branch information
gururajsh committed Dec 17, 2024
1 parent 15fcb76 commit 61394f0
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
20 changes: 17 additions & 3 deletions command/v7/revision_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,26 @@ func (cmd RevisionCommand) Execute(_ []string) error {
})
cmd.UI.DisplayNewline()

app, _, _ := cmd.Actor.GetApplicationByNameAndSpace(appName, cmd.Config.TargetedSpace().GUID)
deployedRevisions, _, _ := cmd.Actor.GetApplicationRevisionsDeployed(app.GUID)
revision, _, _ := cmd.Actor.GetRevisionByApplicationAndVersion(
app, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(appName, cmd.Config.TargetedSpace().GUID)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}

deployedRevisions, warnings, err := cmd.Actor.GetApplicationRevisionsDeployed(app.GUID)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}

revision, warnings, err := cmd.Actor.GetRevisionByApplicationAndVersion(
app.GUID,
cmd.Version.Value,
)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}
isDeployed := revisionDeployed(revision, deployedRevisions)

cmd.displayBasicRevisionInfo(revision, isDeployed)
Expand Down
17 changes: 17 additions & 0 deletions command/v7/revision_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,23 @@ var _ = Describe("revision Command", func() {
})
})
})

When("there are no revisions available", func() {
BeforeEach(func() {
revision := resources.Revision{
Version: 120,
}
fakeActor.GetRevisionByApplicationAndVersionReturns(
revision,
nil,
errors.New("Revision 120 not found"),
)
})

It("returns 'revision not found'", func() {
Expect(executeErr).To(MatchError("Revision 120 not found"))
})
})
})
})
})
21 changes: 19 additions & 2 deletions integration/v7/isolated/revision_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,27 @@ var _ = Describe("revision command", func() {
})

AfterEach(func() {
// helpers.QuickDeleteOrg(orgName)
helpers.QuickDeleteOrg(orgName)
})

// TODO: #173456870 when app not provided, app does not exist, revision doesn't exist cases
When("the requested revision version does not exist", func() {
BeforeEach(func() {
helpers.WithHelloWorldApp(func(appDir string) {
Eventually(helpers.CF("create-app", appName)).Should(Exit(0))
Eventually(helpers.CF("set-env", appName, "foo", "bar1")).Should(Exit(0))
Eventually(helpers.CF("push", appName, "-p", appDir)).Should(Exit(0))
})
})
It("displays revision not found", func() {
session := helpers.CF("revision", appName, "--version", "125")
Eventually(session).Should(Exit(1))

Expect(session).Should(Say(
fmt.Sprintf("Showing revision 125 for app %s in org %s / space %s as %s...", appName, orgName, spaceName, username),
))
Expect(session.Err).Should(Say("Revision '125' not found"))
})
})

When("the requested app and revision both exist", func() {
BeforeEach(func() {
Expand Down

0 comments on commit 61394f0

Please sign in to comment.