summaryrefslogtreecommitdiff
path: root/libpod/image/parts_test.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-04-22 08:01:12 +0200
committerValentin Rothberg <rothberg@redhat.com>2021-05-05 11:30:12 +0200
commit0f7d54b0260c1be992ee3b9cee359ef3a9e8bd21 (patch)
tree192e52054de2abf0c92d83ecdbc71d498c2ec947 /libpod/image/parts_test.go
parent8eefca5a257121b177562742c972e39e1686140d (diff)
downloadpodman-0f7d54b0260c1be992ee3b9cee359ef3a9e8bd21.tar.gz
podman-0f7d54b0260c1be992ee3b9cee359ef3a9e8bd21.tar.bz2
podman-0f7d54b0260c1be992ee3b9cee359ef3a9e8bd21.zip
migrate Podman to containers/common/libimage
Migrate the Podman code base over to `common/libimage` which replaces `libpod/image` and a lot of glue code entirely. Note that I tried to leave bread crumbs for changed tests. Miscellaneous changes: * Some errors yield different messages which required to alter some tests. * I fixed some pre-existing issues in the code. Others were marked as `//TODO`s to prevent the PR from exploding. * The `NamesHistory` of an image is returned as is from the storage. Previously, we did some filtering which I think is undesirable. Instead we should return the data as stored in the storage. * Touched handlers use the ABI interfaces where possible. * Local image resolution: previously Podman would match "foo" on "myfoo". This behaviour has been changed and Podman will now only match on repository boundaries such that "foo" would match "my/foo" but not "myfoo". I consider the old behaviour to be a bug, at the very least an exotic corner case. * Futhermore, "foo:none" does *not* resolve to a local image "foo" without tag anymore. It's a hill I am (almost) willing to die on. * `image prune` prints the IDs of pruned images. Previously, in some cases, the names were printed instead. The API clearly states ID, so we should stick to it. * Compat endpoint image removal with _force_ deletes the entire not only the specified tag. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'libpod/image/parts_test.go')
-rw-r--r--libpod/image/parts_test.go123
1 files changed, 0 insertions, 123 deletions
diff --git a/libpod/image/parts_test.go b/libpod/image/parts_test.go
deleted file mode 100644
index 726e55e86..000000000
--- a/libpod/image/parts_test.go
+++ /dev/null
@@ -1,123 +0,0 @@
-package image
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func TestDecompose(t *testing.T) {
- const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
-
- for _, c := range []struct {
- input string
- registry, name, suspiciousTagValueForSearch string
- hasRegistry bool
- }{
- {"#", "", "", "", false}, // Entirely invalid input
- { // Fully qualified docker.io, name-only input
- "docker.io/library/busybox", "docker.io", "library/busybox", "latest", true,
- },
- { // Fully qualified example.com, name-only input
- "example.com/ns/busybox", "example.com", "ns/busybox", "latest", true,
- },
- { // Unqualified single-name input
- "busybox", "", "busybox", "latest", false,
- },
- { // Unqualified namespaced input
- "ns/busybox", "", "ns/busybox", "latest", false,
- },
- { // name:tag
- "example.com/ns/busybox:notlatest", "example.com", "ns/busybox", "notlatest", true,
- },
- { // name@digest
- // FIXME? .suspiciousTagValueForSearch == "none"
- "example.com/ns/busybox" + digestSuffix, "example.com", "ns/busybox", "none", true,
- },
- { // name:tag@digest
- "example.com/ns/busybox:notlatest" + digestSuffix, "example.com", "ns/busybox", "notlatest", true,
- },
- } {
- parts, err := decompose(c.input)
- if c.name == "" {
- assert.Error(t, err, c.input)
- } else {
- assert.NoError(t, err, c.input)
- registry, name, suspiciousTagValueForSearch := parts.suspiciousRefNameTagValuesForSearch()
- assert.Equal(t, c.registry, registry, c.input)
- assert.Equal(t, c.name, name, c.input)
- assert.Equal(t, c.suspiciousTagValueForSearch, suspiciousTagValueForSearch, c.input)
- assert.Equal(t, c.hasRegistry, parts.hasRegistry, c.input)
- }
- }
-}
-
-func TestImagePartsReferenceWithRegistry(t *testing.T) {
- const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
-
- for _, c := range []struct {
- input string
- withDocker, withNonDocker string
- }{
- {"example.com/ns/busybox", "", ""}, // Fully-qualified input is invalid.
- {"busybox", "docker.io/library/busybox", "example.com/busybox"}, // Single-name input
- {"ns/busybox", "docker.io/ns/busybox", "example.com/ns/busybox"}, // Namespaced input
- {"ns/busybox:notlatest", "docker.io/ns/busybox:notlatest", "example.com/ns/busybox:notlatest"}, // name:tag
- {"ns/busybox" + digestSuffix, "docker.io/ns/busybox" + digestSuffix, "example.com/ns/busybox" + digestSuffix}, // name@digest
- { // name:tag@digest
- "ns/busybox:notlatest" + digestSuffix,
- "docker.io/ns/busybox:notlatest" + digestSuffix, "example.com/ns/busybox:notlatest" + digestSuffix,
- },
- } {
- parts, err := decompose(c.input)
- require.NoError(t, err)
- if c.withDocker == "" {
- _, err := parts.referenceWithRegistry("docker.io")
- assert.Error(t, err, c.input)
- _, err = parts.referenceWithRegistry("example.com")
- assert.Error(t, err, c.input)
- } else {
- ref, err := parts.referenceWithRegistry("docker.io")
- require.NoError(t, err, c.input)
- assert.Equal(t, c.withDocker, ref.String())
- ref, err = parts.referenceWithRegistry("example.com")
- require.NoError(t, err, c.input)
- assert.Equal(t, c.withNonDocker, ref.String())
- }
- }
-
- // Invalid registry value
- parts, err := decompose("busybox")
- require.NoError(t, err)
- _, err = parts.referenceWithRegistry("invalid@domain")
- assert.Error(t, err)
-}
-
-func TestImagePartsNormalizedReference(t *testing.T) {
- const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
-
- for _, c := range []struct{ input, expected string }{
- {"busybox", ""}, // Unqualified input is invalid
- {"docker.io/busybox", "docker.io/library/busybox"}, // docker.io single-name
- {"example.com/busybox", "example.com/busybox"}, // example.com single-name
- {"docker.io/ns/busybox", "docker.io/ns/busybox"}, // docker.io namespaced
- {"example.com/ns/busybox", "example.com/ns/busybox"}, // example.com namespaced
- {"example.com/ns/busybox:notlatest", "example.com/ns/busybox:notlatest"}, // name:tag
- {"example.com/ns/busybox" + digestSuffix, "example.com/ns/busybox" + digestSuffix}, // name@digest
- { // name:tag@digest
- "example.com/ns/busybox:notlatest" + digestSuffix, "example.com/ns/busybox:notlatest" + digestSuffix,
- },
- } {
- parts, err := decompose(c.input)
- require.NoError(t, err)
- if c.expected == "" {
- _, err := parts.normalizedReference()
- assert.Error(t, err, c.input)
- } else {
- ref, err := parts.normalizedReference()
- require.NoError(t, err, c.input)
- assert.Equal(t, c.expected, ref.String())
- }
- }
-}