diff --git a/command/status.go b/command/status.go index c515c822d..12dcc83ed 100644 --- a/command/status.go +++ b/command/status.go @@ -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 diff --git a/command/status_test.go b/command/status_test.go index f28bc773f..ae784cfb4 100644 --- a/command/status_test.go +++ b/command/status_test.go @@ -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()