From 19d6519399ff37d6c2c648bfbd6dbf99de0b19e5 Mon Sep 17 00:00:00 2001 From: Bob Callaway <bobcallaway@users.noreply.github.com> Date: Tue, 27 Jul 2021 05:55:17 -0400 Subject: [PATCH] return exit code of 1 if no results found (#386) Signed-off-by: Bob Callaway <bob.callaway@gmail.com> --- cmd/rekor-cli/app/search.go | 4 ++++ tests/e2e_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cmd/rekor-cli/app/search.go b/cmd/rekor-cli/app/search.go index 335d450..e447d23 100644 --- a/cmd/rekor-cli/app/search.go +++ b/cmd/rekor-cli/app/search.go @@ -196,6 +196,10 @@ var searchCmd = &cobra.Command{ } } + if len(resp.Payload) == 0 { + return nil, fmt.Errorf("no matching entries found") + } + return &searchCmdOutput{ uuids: resp.GetPayload(), }, nil diff --git a/tests/e2e_test.go b/tests/e2e_test.go index a5f62a7..c210793 100644 --- a/tests/e2e_test.go +++ b/tests/e2e_test.go @@ -226,6 +226,10 @@ func TestGet(t *testing.T) { outputContains(t, out, uuid) } +func TestSearchNoEntriesRC1(t *testing.T) { + runCliErr(t, "search", "--email", "noone@internetz.com") +} + func TestMinisign(t *testing.T) { // Create a keypair keyPath := filepath.Join(t.TempDir(), "minisign.key") -- GitLab