diff options
author | Miloslav Trmač <mitr@redhat.com> | 2018-08-02 00:05:52 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-02 13:17:17 +0000 |
commit | 5334d9ab5e20a53bc92b809e6a3dd2bcacb1bf47 (patch) | |
tree | 6fff3b53c59bdf8d9e9f7943d0154dea2dcd27b5 /libpod/image/pull_test.go | |
parent | 682076e58f78fccc1a5a4561ce71dfcf60880699 (diff) | |
download | podman-5334d9ab5e20a53bc92b809e6a3dd2bcacb1bf47.tar.gz podman-5334d9ab5e20a53bc92b809e6a3dd2bcacb1bf47.tar.bz2 podman-5334d9ab5e20a53bc92b809e6a3dd2bcacb1bf47.zip |
Replace getPullRefName by Runtime.getPullRefPair
This more or less reverts 9c9401a96c0b7d43dcea19c2972ef9612cc0a136
"Replace getPullRefPair with getPullRefName"; now that tests don't require
us to use pullRefName, move creation of storage references deeper into the
calls stack to reduce string use.
ir.getSinglePullRefNameGoal is accordingly updated to ir.getSinglePullRefPairGoal,
and we need to add a ~duplicate singlePullRefPairGoal; that duplication
of singlePullRefNameGoal will soon be resolved by dropping singlePullRefNameGoal.
Should not change behavior.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #1198
Approved by: mheon
Diffstat (limited to 'libpod/image/pull_test.go')
-rw-r--r-- | libpod/image/pull_test.go | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/libpod/image/pull_test.go b/libpod/image/pull_test.go index a2e642d51..5ef8c47a5 100644 --- a/libpod/image/pull_test.go +++ b/libpod/image/pull_test.go @@ -61,16 +61,18 @@ func storageReferenceWithoutLocation(ref types.ImageReference) string { return res } -func TestGetPullRefName(t *testing.T) { +func TestGetPullRefPair(t *testing.T) { const imageID = "@0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + ir, cleanup := newTestRuntime(t) + defer cleanup() + for _, c := range []struct{ srcName, destName, expectedImage, expectedDstName string }{ // == Source does not have a Docker reference (as is the case for docker-archive:, oci-archive, dir:); destination formats: { // registry/name, no tag: "dir:/dev/this-does-not-exist", "example.com/from-directory", - // The destName value will be interpreted as "example.com/from-directory:latest" by storageTransport. - "example.com/from-directory", "example.com/from-directory", + "example.com/from-directory", "example.com/from-directory:latest", }, { // name, no registry, no tag: "dir:/dev/this-does-not-exist", "from-directory", @@ -98,7 +100,7 @@ func TestGetPullRefName(t *testing.T) { { // ns/name:tag, no registry: // FIXME: This is interpreted as "registry == ns" "dir:/dev/this-does-not-exist", "ns/from-directory:notlatest", - "ns/from-directory:notlatest", "ns/from-directory:notlatest", + "ns/from-directory:notlatest", "docker.io/ns/from-directory:notlatest", }, { // containers-storage image ID "dir:/dev/this-does-not-exist", imageID, @@ -116,13 +118,22 @@ func TestGetPullRefName(t *testing.T) { "docker://busybox", "docker://busybox:destination", "docker://busybox:destination", "docker.io/library/busybox:latest", }, + // == Invalid destination format. + {"tarball:/dev/null", "tarball:/dev/null", "", ""}, } { + testDescription := fmt.Sprintf("%#v %#v", c.srcName, c.destName) srcRef, err := alltransports.ParseImageName(c.srcName) - require.NoError(t, err, c.srcName) + require.NoError(t, err, testDescription) - res := getPullRefName(srcRef, c.destName) - assert.Equal(t, pullRefName{image: c.expectedImage, srcRef: srcRef, dstName: c.expectedDstName}, res, - fmt.Sprintf("%#v %#v", c.srcName, c.destName)) + res, err := ir.getPullRefPair(srcRef, c.destName) + if c.expectedDstName == "" { + assert.Error(t, err, testDescription) + } else { + require.NoError(t, err, testDescription) + assert.Equal(t, c.expectedImage, res.image, testDescription) + assert.Equal(t, srcRef, res.srcRef, testDescription) + assert.Equal(t, c.expectedDstName, storageReferenceWithoutLocation(res.dstRef), testDescription) + } } } |