Skip to content

Commit

Permalink
add prefix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Aug 29, 2017
1 parent b86e05b commit e3710a9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions command/alloc_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ func TestAllocStatusCommand_Run(t *testing.T) {
t.Fatalf("expected to have 'Created At' but saw: %s", out)
}
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) {
Expand Down
2 changes: 1 addition & 1 deletion command/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestMonitor_MonitorWithPrefix(t *testing.T) {
doneCh := make(chan struct{})
go func() {
defer close(doneCh)
code = mon.monitor(resp.EvalID[:8], true)
code = mon.monitor(resp.EvalID[:13], true)
}()

// Wait for completion
Expand Down
4 changes: 2 additions & 2 deletions command/node_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ func TestNodeStatusCommand_Run(t *testing.T) {
t.Fatalf("should not dump allocations")
}

// Query a single node based on prefix
if code := cmd.Run([]string{"-address=" + url, nodeID[:4]}); code != 0 {
// Query a single node based on a prefix that is even without the hyphen
if code := cmd.Run([]string{"-address=" + url, nodeID[:13]}); code != 0 {
t.Fatalf("expected exit 0, got: %d", code)
}
out = ui.OutputWriter.String()
Expand Down

0 comments on commit e3710a9

Please sign in to comment.