github.com/jrxfive/nomad@v0.6.1-0.20170802162750-1fef470e89bf/command/deployment_status_test.go (about) 1 package command 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/mitchellh/cli" 8 ) 9 10 func TestDeploymentStatusCommand_Implements(t *testing.T) { 11 t.Parallel() 12 var _ cli.Command = &DeploymentStatusCommand{} 13 } 14 15 func TestDeploymentStatusCommand_Fails(t *testing.T) { 16 t.Parallel() 17 ui := new(cli.MockUi) 18 cmd := &DeploymentStatusCommand{Meta: Meta{Ui: ui}} 19 20 // Fails on misuse 21 if code := cmd.Run([]string{"some", "bad", "args"}); code != 1 { 22 t.Fatalf("expected exit code 1, got: %d", code) 23 } 24 if out := ui.ErrorWriter.String(); !strings.Contains(out, cmd.Help()) { 25 t.Fatalf("expected help output, got: %s", out) 26 } 27 ui.ErrorWriter.Reset() 28 29 if code := cmd.Run([]string{"-address=nope", "12"}); code != 1 { 30 t.Fatalf("expected exit code 1, got: %d", code) 31 } 32 if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error retrieving deployment") { 33 t.Fatalf("expected failed query error, got: %s", out) 34 } 35 ui.ErrorWriter.Reset() 36 }