github.com/smithx10/nomad@v0.9.1-rc1/command/deployment_list_test.go (about)

     1  package command
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/mitchellh/cli"
     8  )
     9  
    10  func TestDeploymentListCommand_Implements(t *testing.T) {
    11  	t.Parallel()
    12  	var _ cli.Command = &DeploymentListCommand{}
    13  }
    14  
    15  func TestDeploymentListCommand_Fails(t *testing.T) {
    16  	t.Parallel()
    17  	ui := new(cli.MockUi)
    18  	cmd := &DeploymentListCommand{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, commandErrorText(cmd)) {
    25  		t.Fatalf("expected help output, got: %s", out)
    26  	}
    27  	ui.ErrorWriter.Reset()
    28  
    29  	if code := cmd.Run([]string{"-address=nope"}); code != 1 {
    30  		t.Fatalf("expected exit code 1, got: %d", code)
    31  	}
    32  	if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error retrieving deployments") {
    33  		t.Fatalf("expected failed query error, got: %s", out)
    34  	}
    35  	ui.ErrorWriter.Reset()
    36  }