Return with an error code when searching after not finding password (#198)

* Return with an error code when searching after not finding password

* Fix integration tests for returning error code when running search
This commit is contained in:
Matthias Loibl 2017-07-19 15:20:48 +02:00 committed by Dominik Schulz
parent d249f0077d
commit 5229378b8d
3 changed files with 9 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package action
import (
"fmt"
"os"
"github.com/atotto/clipboard"
"github.com/fatih/color"
@ -72,7 +73,10 @@ func (s *Action) Show(c *cli.Context) error {
return err
}
color.Yellow("Entry '%s' not found. Starting search...", name)
return s.Find(c)
if err := s.Find(c); err != nil {
return err
}
os.Exit(1)
}
}

View File

@ -27,8 +27,8 @@ func TestSingleMount(t *testing.T) {
assert.NoError(t, err)
out, err = ts.run("show mnt/m1/secret")
assert.NoError(t, err)
assert.Equal(t, "Entry 'mnt/m1/secret' not found. Starting search...", out)
assert.Error(t, err)
assert.Equal(t, "Entry 'mnt/m1/secret' not found. Starting search...\n", out)
ts.initSecrets("mnt/m1/")

View File

@ -20,8 +20,8 @@ func TestShow(t *testing.T) {
assert.Equal(t, "\nError: provide a secret name\n", out)
out, err = ts.run("show foo")
assert.NoError(t, err)
assert.Equal(t, "Entry 'foo' not found. Starting search...", out)
assert.Error(t, err)
assert.Equal(t, "Entry 'foo' not found. Starting search...\n", out)
ts.initSecrets("")