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:
Armon Dadgar 2014-05-04 13:38:25 -07:00
commit 186c116fc6
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)
}
// No matching members
if len(result) == 0 {
return 2
}
// Generate the columnized version
output := columnize.SimpleFormat(result)
c.Ui.Output(string(output))

View File

@ -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)
}
}