Merge pull request #11163 from duglin/RmiTest
Better error message for `docker rmi ''`
This commit is contained in:
commit
214eae6f53
2 changed files with 19 additions and 1 deletions
|
@ -41,6 +41,10 @@ func (daemon *Daemon) DeleteImage(eng *engine.Engine, name string, imgs *engine.
|
|||
tag = graph.DEFAULTTAG
|
||||
}
|
||||
|
||||
if name == "" {
|
||||
return fmt.Errorf("Image name can not be blank")
|
||||
}
|
||||
|
||||
img, err := daemon.Repositories().LookupImage(name)
|
||||
if err != nil {
|
||||
if r, _ := daemon.Repositories().Get(repoName); r != nil {
|
||||
|
|
|
@ -155,5 +155,19 @@ func TestRmiWithMultipleRepositories(t *testing.T) {
|
|||
}
|
||||
|
||||
logDone("rmi - delete a image which its dependency tagged to multiple repositories success")
|
||||
|
||||
}
|
||||
|
||||
func TestRmiBlank(t *testing.T) {
|
||||
// try to delete a blank image name
|
||||
runCmd := exec.Command(dockerBinary, "rmi", "")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
|
||||
if err == nil {
|
||||
t.Fatal("Should have failed to delete '' image")
|
||||
}
|
||||
|
||||
if strings.Contains(out, "No such image") {
|
||||
t.Fatalf("Wrong error message generated: %s", out)
|
||||
}
|
||||
logDone("rmi- blank image name")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue