diff --git a/command/members.go b/command/members.go index f9244230a0..144d9739a7 100644 --- a/command/members.go +++ b/command/members.go @@ -102,6 +102,11 @@ func (c *MembersCommand) Run(args []string) int { result = append(result, line) } + // No matching members + if len(result) == 0 { + return 2 + } + // Generate the columnized version output := columnize.SimpleFormat(result) c.Ui.Output(string(output)) diff --git a/command/members_test.go b/command/members_test.go index 47a27ffb99..21a959f3e8 100644 --- a/command/members_test.go +++ b/command/members_test.go @@ -80,13 +80,17 @@ func TestMembersCommandRun_statusFilter_failed(t *testing.T) { } code := c.Run(args) - if code != 0 { + if code == 1 { t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String()) } if strings.Contains(ui.OutputWriter.String(), a1.config.NodeName) { t.Fatalf("bad: %#v", ui.OutputWriter.String()) } + + if code != 2 { + t.Fatalf("bad: %d", code) + } } func TestMembersCommandRun_roleFilter(t *testing.T) { @@ -122,11 +126,15 @@ func TestMembersCommandRun_roleFilter_failed(t *testing.T) { } code := c.Run(args) - if code != 0 { + if code == 1 { t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String()) } if strings.Contains(ui.OutputWriter.String(), a1.config.NodeName) { t.Fatalf("bad: %#v", ui.OutputWriter.String()) } + + if code != 2 { + t.Fatalf("bad: %d", code) + } }