Return exit code 2 if member filter doesn't match any node

pull/116/head
William Tisäter 2014-05-04 11:54:45 +02:00
parent d2e09b66ab
commit b278d1de94
2 changed files with 15 additions and 2 deletions

View File

@ -102,6 +102,11 @@ func (c *MembersCommand) Run(args []string) int {
result = append(result, line) result = append(result, line)
} }
// No matching members
if len(result) == 0 {
return 2
}
// Generate the columnized version // Generate the columnized version
output := columnize.SimpleFormat(result) output := columnize.SimpleFormat(result)
c.Ui.Output(string(output)) c.Ui.Output(string(output))

View File

@ -80,13 +80,17 @@ func TestMembersCommandRun_statusFilter_failed(t *testing.T) {
} }
code := c.Run(args) code := c.Run(args)
if code != 0 { if code == 1 {
t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String()) t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
} }
if strings.Contains(ui.OutputWriter.String(), a1.config.NodeName) { if strings.Contains(ui.OutputWriter.String(), a1.config.NodeName) {
t.Fatalf("bad: %#v", ui.OutputWriter.String()) t.Fatalf("bad: %#v", ui.OutputWriter.String())
} }
if code != 2 {
t.Fatalf("bad: %d", code)
}
} }
func TestMembersCommandRun_roleFilter(t *testing.T) { func TestMembersCommandRun_roleFilter(t *testing.T) {
@ -122,11 +126,15 @@ func TestMembersCommandRun_roleFilter_failed(t *testing.T) {
} }
code := c.Run(args) code := c.Run(args)
if code != 0 { if code == 1 {
t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String()) t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
} }
if strings.Contains(ui.OutputWriter.String(), a1.config.NodeName) { if strings.Contains(ui.OutputWriter.String(), a1.config.NodeName) {
t.Fatalf("bad: %#v", ui.OutputWriter.String()) t.Fatalf("bad: %#v", ui.OutputWriter.String())
} }
if code != 2 {
t.Fatalf("bad: %d", code)
}
} }