aboutsummaryrefslogtreecommitdiff
path: root/libpod/image/parts_test.go
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2019-01-09 19:41:50 +0100
committerMiloslav Trmač <mitr@redhat.com>2019-01-14 04:07:24 +0100
commitfa42f97507f5b5c661df2339603383b00293689f (patch)
tree5bb4fc5f9c540b3cdc7de867c45488234ac09403 /libpod/image/parts_test.go
parentcf40b7161476414e7abecd19d9d9eefacd8a4ef7 (diff)
downloadpodman-fa42f97507f5b5c661df2339603383b00293689f.tar.gz
podman-fa42f97507f5b5c661df2339603383b00293689f.tar.bz2
podman-fa42f97507f5b5c661df2339603383b00293689f.zip
FIXME? Introduce imageParts.suspiciousRefNameTagValuesForSearch
Image.MatchRepoTag and findImageInRepoTags do some kind of heuristic search; the motivation and design of both, and how they should deal with digests, is not obvious to me. Instead of figuring that out now, just factor it out into a scary-named method and leave the "tag" value (with its "latest"/"none" value) alone. Similarly, the .registry and .name fields should typically not be used; users should use either hasRegistry or normalized reference types; so, isolate the difficult-to-understand search code, and computation of these values, into this new search-specific helper. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'libpod/image/parts_test.go')
-rw-r--r--libpod/image/parts_test.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/libpod/image/parts_test.go b/libpod/image/parts_test.go
index 9955a20ea..dd4a7b27f 100644
--- a/libpod/image/parts_test.go
+++ b/libpod/image/parts_test.go
@@ -11,9 +11,9 @@ func TestDecompose(t *testing.T) {
const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
for _, c := range []struct {
- input string
- registry, name, tag string
- isTagged, hasRegistry bool
+ input string
+ registry, name, suspiciousTagValueForSearch string
+ isTagged, hasRegistry bool
}{
{"#", "", "", "", false, false}, // Entirely invalid input
{ // Fully qualified docker.io, name-only input
@@ -32,7 +32,7 @@ func TestDecompose(t *testing.T) {
"example.com/ns/busybox:notlatest", "example.com", "ns/busybox", "notlatest", true, true,
},
{ // name@digest
- // FIXME? .tag == "none"
+ // FIXME? .suspiciousTagValueForSearch == "none"
"example.com/ns/busybox" + digestSuffix, "example.com", "ns/busybox", "none", false, true,
},
{ // name:tag@digest
@@ -44,9 +44,10 @@ func TestDecompose(t *testing.T) {
assert.Error(t, err, c.input)
} else {
assert.NoError(t, err, c.input)
- assert.Equal(t, c.registry, parts.registry, c.input)
- assert.Equal(t, c.name, parts.name, c.input)
- assert.Equal(t, c.tag, parts.tag, 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.isTagged, parts.isTagged, c.input)
assert.Equal(t, c.hasRegistry, parts.hasRegistry, c.input)
}