diff --git a/cmd/snapshot_search.go b/cmd/snapshot_search.go index d1aee367..6b896a5d 100644 --- a/cmd/snapshot_search.go +++ b/cmd/snapshot_search.go @@ -96,6 +96,10 @@ func aptlySnapshotMirrorRepoSearch(cmd *commander.Command, args []string) error return fmt.Errorf("unable to search: %s", err) } + if result.Len() == 0 { + return fmt.Errorf("no results") + } + result.ForEach(func(p *deb.Package) error { context.Progress().Printf("%s\n", p) return nil diff --git a/system/t05_snapshot/SearchSnapshot5Test_gold b/system/t05_snapshot/SearchSnapshot5Test_gold new file mode 100644 index 00000000..2d08b563 --- /dev/null +++ b/system/t05_snapshot/SearchSnapshot5Test_gold @@ -0,0 +1 @@ +ERROR: no results diff --git a/system/t05_snapshot/search.py b/system/t05_snapshot/search.py index 3a065675..9133b333 100644 --- a/system/t05_snapshot/search.py +++ b/system/t05_snapshot/search.py @@ -37,3 +37,13 @@ class SearchSnapshot4Test(BaseTest): fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"] outputMatchPrepare = lambda _, s: "\n".join(sorted(s.split("\n"))) runCmd = "aptly snapshot search -with-deps wheezy-main 'Name (nginx)'" + + +class SearchSnapshot5Test(BaseTest): + """ + search snapshot: no results + """ + fixtureDB = True + fixtureCmds = ["aptly snapshot create wheezy-main from mirror wheezy-main"] + runCmd = "aptly snapshot search -with-deps wheezy-main 'Name (no-such-package)'" + expectedCode = 1