diff options
author | baude <bbaude@redhat.com> | 2018-03-21 13:08:32 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-22 19:06:51 +0000 |
commit | d364d41e1b1cf42d11b383fb02fbaa07e8b156f7 (patch) | |
tree | ced7036c6dbb7e6a6659f79153618b910009386e /libpod/image/image_test.go | |
parent | 2cc51dbb1c0eff1d193e41a8d7e898830c186791 (diff) | |
download | podman-d364d41e1b1cf42d11b383fb02fbaa07e8b156f7.tar.gz podman-d364d41e1b1cf42d11b383fb02fbaa07e8b156f7.tar.bz2 podman-d364d41e1b1cf42d11b383fb02fbaa07e8b156f7.zip |
Removing tagged images change in behavior
An image name is really just a tag. When an image has multiple tags, we should be
able to "delete" the one of its tags without harm. In this case, the "delete' is
really a form of Untag (removing the tag from the image).
If an image has multiple tags and the user tries to delete by ID without force, this
should be denied because when you delete by ID there is no distinguishing it like
image tags.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #528
Approved by: mheon
Diffstat (limited to 'libpod/image/image_test.go')
-rw-r--r-- | libpod/image/image_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libpod/image/image_test.go b/libpod/image/image_test.go index d9e8987a6..5c7cc191d 100644 --- a/libpod/image/image_test.go +++ b/libpod/image/image_test.go @@ -136,3 +136,52 @@ func TestImage_New(t *testing.T) { // Shutdown the runtime and remove the temporary storage cleanup(workdir, ir) } + +// TestImage_MatchRepoTag tests the various inputs we need to match +// against an image's reponames +func TestImage_MatchRepoTag(t *testing.T) { + //Set up + workdir, err := mkWorkDir() + assert.NoError(t, err) + + so := storage.StoreOptions{ + RunRoot: workdir, + GraphRoot: workdir, + } + ir, err := NewImageRuntimeFromOptions(so) + assert.NoError(t, err) + newImage, err := ir.New("busybox", "", "", os.Stdout, nil, SigningOptions{}) + assert.NoError(t, err) + err = newImage.TagImage("foo:latest") + assert.NoError(t, err) + err = newImage.TagImage("foo:bar") + assert.NoError(t, err) + + // Tests start here. + for _, name := range bbNames { + repoTag, err := newImage.MatchRepoTag(name) + assert.NoError(t, err) + assert.Equal(t, "docker.io/library/busybox:latest", repoTag) + } + + // Test against tagged images of busybox + // foo should resolve to foo:latest + repoTag, err := newImage.MatchRepoTag("foo") + assert.NoError(t, err) + assert.Equal(t, "foo:latest", repoTag) + + // foo:bar should resolve to foo:bar + repoTag, err = newImage.MatchRepoTag("foo:bar") + assert.NoError(t, err) + assert.Equal(t, "foo:bar", repoTag) + // Shutdown the runtime and remove the temporary storage + cleanup(workdir, ir) +} + +// Test_splitString tests the splitString function in image that +// takes input and splits on / and returns the last array item +func Test_splitString(t *testing.T) { + assert.Equal(t, splitString("foo/bar"), "bar") + assert.Equal(t, splitString("a/foo/bar"), "bar") + assert.Equal(t, splitString("bar"), "bar") +} |