add prefix tests

This commit is contained in:
Alex Dadgar 2017-08-29 10:09:30 -07:00
parent 52fa3396e7
commit f99b13c141
3 changed files with 22 additions and 3 deletions

View file

@ -144,6 +144,25 @@ func TestAllocStatusCommand_Run(t *testing.T) {
t.Fatalf("expected to have 'Created At' but saw: %s", out) t.Fatalf("expected to have 'Created At' but saw: %s", out)
} }
ui.OutputWriter.Reset() ui.OutputWriter.Reset()
// Try the query with an even prefix that includes the hyphen
if code := cmd.Run([]string{"-address=" + url, allocId1[:13]}); code != 0 {
t.Fatalf("expected exit 0, got: %d", code)
}
out = ui.OutputWriter.String()
if !strings.Contains(out, "Created At") {
t.Fatalf("expected to have 'Created At' but saw: %s", out)
}
ui.OutputWriter.Reset()
if code := cmd.Run([]string{"-address=" + url, "-verbose", allocId1}); code != 0 {
t.Fatalf("expected exit 0, got: %d", code)
}
out = ui.OutputWriter.String()
if !strings.Contains(out, allocId1) {
t.Fatal("expected to find alloc id in output")
}
ui.OutputWriter.Reset()
} }
func TestAllocStatusCommand_AutocompleteArgs(t *testing.T) { func TestAllocStatusCommand_AutocompleteArgs(t *testing.T) {

View file

@ -239,7 +239,7 @@ func TestMonitor_MonitorWithPrefix(t *testing.T) {
doneCh := make(chan struct{}) doneCh := make(chan struct{})
go func() { go func() {
defer close(doneCh) defer close(doneCh)
code = mon.monitor(resp.EvalID[:8], true) code = mon.monitor(resp.EvalID[:13], true)
}() }()
// Wait for completion // Wait for completion

View file

@ -127,8 +127,8 @@ func TestNodeStatusCommand_Run(t *testing.T) {
t.Fatalf("should not dump allocations") t.Fatalf("should not dump allocations")
} }
// Query a single node based on prefix // Query a single node based on a prefix that is even without the hyphen
if code := cmd.Run([]string{"-address=" + url, nodeID[:4]}); code != 0 { if code := cmd.Run([]string{"-address=" + url, nodeID[:13]}); code != 0 {
t.Fatalf("expected exit 0, got: %d", code) t.Fatalf("expected exit 0, got: %d", code)
} }
out = ui.OutputWriter.String() out = ui.OutputWriter.String()