Add tests for rmi

Add integration test for removing by image id with tag and digest reference to the same repository.
Add integration test to ensure only tag to other repository remains after deleting tag with accompanying digest reference.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2016-06-17 09:18:27 -07:00
parent a281be1c11
commit 5cff374b14
1 changed files with 39 additions and 0 deletions

View File

@ -380,9 +380,14 @@ func (s *DockerRegistrySuite) TestDeleteImageByIDOnlyPulledByDigest(c *check.C)
dockerCmd(c, "pull", imageReference)
// just in case...
dockerCmd(c, "tag", imageReference, repoName+":sometag")
imageID := inspectField(c, imageReference, "Id")
dockerCmd(c, "rmi", imageID)
_, err = inspectFieldWithError(imageID, "Id")
c.Assert(err, checker.NotNil, check.Commentf("image should have been deleted"))
}
func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndTag(c *check.C) {
@ -412,6 +417,40 @@ func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndTag(c *check.C) {
c.Assert(err, checker.NotNil, check.Commentf("image should have been deleted"))
}
func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndMultiRepoTag(c *check.C) {
pushDigest, err := setupImage(c)
c.Assert(err, checker.IsNil, check.Commentf("error setting up image"))
repo2 := fmt.Sprintf("%s/%s", repoName, "repo2")
// pull from the registry using the <name>@<digest> reference
imageReference := fmt.Sprintf("%s@%s", repoName, pushDigest)
dockerCmd(c, "pull", imageReference)
imageID := inspectField(c, imageReference, "Id")
repoTag := repoName + ":sometag"
repoTag2 := repo2 + ":othertag"
dockerCmd(c, "tag", imageReference, repoTag)
dockerCmd(c, "tag", imageReference, repoTag2)
dockerCmd(c, "rmi", repoTag)
// rmi should have deleted repoTag and image reference, but left repoTag2
inspectField(c, repoTag2, "Id")
_, err = inspectFieldWithError(imageReference, "Id")
c.Assert(err, checker.NotNil, check.Commentf("image digest reference should have been removed"))
_, err = inspectFieldWithError(repoTag, "Id")
c.Assert(err, checker.NotNil, check.Commentf("image tag reference should have been removed"))
dockerCmd(c, "rmi", repoTag2)
// rmi should have deleted the tag, the digest reference, and the image itself
_, err = inspectFieldWithError(imageID, "Id")
c.Assert(err, checker.NotNil, check.Commentf("image should have been deleted"))
}
// TestPullFailsWithAlteredManifest tests that a `docker pull` fails when
// we have modified a manifest blob and its digest cannot be verified.
// This is the schema2 version of the test.