When nothing found in stack exit with exit code 1

To keep on a consistent behaviour such as in docker-service-ps
if docker-stack-ps didn't find a given stack, the command line
should exit with exit code 1.

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
This commit is contained in:
Boaz Shuster 2017-08-30 13:47:53 +03:00
parent 65202d669a
commit 79f9af2475
2 changed files with 3 additions and 4 deletions

View File

@ -57,8 +57,7 @@ func runPS(dockerCli command.Cli, options psOptions) error {
} }
if len(tasks) == 0 { if len(tasks) == 0 {
fmt.Fprintf(dockerCli.Err(), "Nothing found in stack: %s\n", namespace) return fmt.Errorf("nothing found in stack: %s", namespace)
return nil
} }
format := options.format format := options.format

View File

@ -60,9 +60,9 @@ func TestStackPsEmptyStack(t *testing.T) {
cmd := newPsCommand(fakeCli) cmd := newPsCommand(fakeCli)
cmd.SetArgs([]string{"foo"}) cmd.SetArgs([]string{"foo"})
assert.NoError(t, cmd.Execute()) assert.Error(t, cmd.Execute())
assert.EqualError(t, cmd.Execute(), "nothing found in stack: foo")
assert.Equal(t, "", fakeCli.OutBuffer().String()) assert.Equal(t, "", fakeCli.OutBuffer().String())
assert.Equal(t, "Nothing found in stack: foo\n", fakeCli.ErrBuffer().String())
} }
func TestStackPsWithQuietOption(t *testing.T) { func TestStackPsWithQuietOption(t *testing.T) {