get status of deployment via status cli command

This commit is contained in:
Chelsea Holland Komlo
2017-08-25 21:06:33 +00:00
parent 732328e6ae
commit 1fdabecad3
2 changed files with 28 additions and 0 deletions

View File

@@ -129,6 +129,8 @@ func (c *StatusCommand) Run(args []string) int {
cmd = &AllocStatusCommand{Meta: c.Meta}
case contexts.Jobs:
cmd = &JobStatusCommand{Meta: c.Meta}
case contexts.Deployments:
cmd = &DeploymentStatusCommand{Meta: c.Meta}
default:
c.Ui.Error(fmt.Sprintf("Unable to resolve ID: %q", id))
return 1

View File

@@ -130,6 +130,32 @@ func TestStatusCommand_Run_AllocStatus(t *testing.T) {
ui.OutputWriter.Reset()
}
func TestStatusCommand_Run_DeploymentStatus(t *testing.T) {
assert := assert.New(t)
t.Parallel()
srv, _, url := testServer(t, true, nil)
defer srv.Shutdown()
ui := new(cli.MockUi)
cmd := &StatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
// Create a fake deployment
state := srv.Agent.Server().State()
deployment := mock.Deployment()
assert.Nil(state.UpsertDeployment(1000, deployment))
// Query to check the deployment status
if code := cmd.Run([]string{"-address=" + url, deployment.ID}); code != 0 {
t.Fatalf("expected exit 0, got: %d", code)
}
out := ui.OutputWriter.String()
assert.Contains(out, deployment.ID[:shortId])
ui.OutputWriter.Reset()
}
func TestStatusCommand_Run_NoPrefix(t *testing.T) {
assert := assert.New(t)
t.Parallel()