Merge pull request #11163 from duglin/RmiTest

Better error message for `docker rmi ''`
This commit is contained in:
Phil Estes 2015-03-05 09:49:46 -05:00
Родитель 7125ae00bb eeb36c9348
Коммит 214eae6f53
2 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -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")
}