Merge pull request #116 from tiwilliam/master
command/members: Return exit code 2 if member filter doesn't match any node
This commit is contained in:
commit
186c116fc6
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue