mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #20940 from HackToday/fixsave
Refine error message when save non-exist image
This commit is contained in:
commit
6b0119aefb
2 changed files with 13 additions and 0 deletions
|
@ -170,6 +170,9 @@ func (is *store) Search(term string) (ID, error) {
|
|||
|
||||
dgst, err := is.digestSet.Lookup(term)
|
||||
if err != nil {
|
||||
if err == digest.ErrDigestNotFound {
|
||||
err = fmt.Errorf("No such image: %s", term)
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
return ID(dgst), nil
|
||||
|
|
|
@ -167,6 +167,16 @@ func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) {
|
|||
c.Assert(before, checker.Equals, after, check.Commentf("inspect is not the same after a save / load"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestSaveWithNoExistImage(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
imgName := "foobar-non-existing-image"
|
||||
|
||||
out, _, err := dockerCmdWithError("save", "-o", "test-img.tar", imgName)
|
||||
c.Assert(err, checker.NotNil, check.Commentf("save image should fail for non-existing image"))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf("No such image: %s", imgName))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestSaveMultipleNames(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
repoName := "foobar-save-multi-name-test"
|
||||
|
|
Loading…
Reference in a new issue