command: better test for alloc-status

This commit is contained in:
Ryan Uber 2015-09-27 14:42:04 -07:00
parent 76a3cf3b93
commit 53e676f42a
1 changed files with 11 additions and 0 deletions

View File

@ -12,6 +12,9 @@ func TestAllocStatusCommand_Implements(t *testing.T) {
}
func TestAllocStatusCommand_Fails(t *testing.T) {
srv, _, url := testServer(t, nil)
defer srv.Stop()
ui := new(cli.MockUi)
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}}
@ -31,4 +34,12 @@ func TestAllocStatusCommand_Fails(t *testing.T) {
if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error querying allocation") {
t.Fatalf("expected failed query error, got: %s", out)
}
// Fails on missing alloc
if code := cmd.Run([]string{"-address=" + url, "26470238-5CF2-438F-8772-DC67CFB0705C"}); code != 1 {
t.Fatalf("expected exit 1, got: %d", code)
}
if out := ui.ErrorWriter.String(); !strings.Contains(out, "not found") {
t.Fatalf("expected not found error, got: %s", out)
}
}