summaryrefslogtreecommitdiff
path: root/libpod/image/pull_test.go
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-28 06:02:49 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 18:22:59 +0000
commit86491efea0fcf5ab9e76668b1dadf004a74c62e0 (patch)
tree10c20df0e43771d3cc45b71105874cfa0a7f1ded /libpod/image/pull_test.go
parentfadb14339904264d27a03448de7c74be1c979b4f (diff)
downloadpodman-86491efea0fcf5ab9e76668b1dadf004a74c62e0.tar.gz
podman-86491efea0fcf5ab9e76668b1dadf004a74c62e0.tar.bz2
podman-86491efea0fcf5ab9e76668b1dadf004a74c62e0.zip
Introduce struct pullGoalNames
This is an intermediate version of pullGoal, which exists basically only for easier testing without containers-storage: (i.e. root access) in unit tests. Like pullGoal, we will add more members to make it useful in the future. RFC: Unlike pullGoal, the return value is *pullGoalNames, because there are quite a few (return nil, err) cases which would be more difficult to read when returning a value. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
Diffstat (limited to 'libpod/image/pull_test.go')
-rw-r--r--libpod/image/pull_test.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/libpod/image/pull_test.go b/libpod/image/pull_test.go
index 11525539b..910319de6 100644
--- a/libpod/image/pull_test.go
+++ b/libpod/image/pull_test.go
@@ -78,7 +78,7 @@ func TestGetPullRefName(t *testing.T) {
}
}
-func TestRefNamesFromImageReference(t *testing.T) {
+func TestPullGoalNamesFromImageReference(t *testing.T) {
type expected struct{ image, dstName string }
for _, c := range []struct {
srcName string
@@ -173,14 +173,14 @@ func TestRefNamesFromImageReference(t *testing.T) {
srcRef, err := alltransports.ParseImageName(c.srcName)
require.NoError(t, err, c.srcName)
- res, err := refNamesFromImageReference(context.Background(), srcRef, c.srcName, nil)
+ res, err := pullGoalNamesFromImageReference(context.Background(), srcRef, c.srcName, nil)
if len(c.expected) == 0 {
assert.Error(t, err, c.srcName)
} else {
require.NoError(t, err, c.srcName)
- require.Len(t, res, len(c.expected), c.srcName)
+ require.Len(t, res.refNames, len(c.expected), c.srcName)
for i, e := range c.expected {
- assert.Equal(t, pullRefName{image: e.image, srcRef: srcRef, dstName: e.dstName}, res[i], fmt.Sprintf("%s #%d", c.srcName, i))
+ assert.Equal(t, pullRefName{image: e.image, srcRef: srcRef, dstName: e.dstName}, res.refNames[i], fmt.Sprintf("%s #%d", c.srcName, i))
}
}
}
@@ -190,11 +190,11 @@ const registriesConfWithSearch = `[registries.search]
registries = ['example.com', 'docker.io']
`
-func TestRefNamesFromPossiblyUnqualifiedName(t *testing.T) {
+func TestPullGoalNamesFromPossiblyUnqualifiedName(t *testing.T) {
const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
type pullRefStrings struct{ image, srcRef, dstName string } // pullRefName with string data only
- registriesConf, err := ioutil.TempFile("", "TestRefNamesFromPossiblyUnqualifiedName")
+ registriesConf, err := ioutil.TempFile("", "TestPullGoalNamesFromPossiblyUnqualifiedName")
require.NoError(t, err)
defer registriesConf.Close()
defer os.Remove(registriesConf.Name())
@@ -282,13 +282,13 @@ func TestRefNamesFromPossiblyUnqualifiedName(t *testing.T) {
// Unqualified, name:tag@digest. This code is happy to try, but .srcRef parsing currently rejects such input.
{"busybox:notlatest" + digestSuffix, nil},
} {
- res, err := refNamesFromPossiblyUnqualifiedName(c.input)
+ res, err := pullGoalNamesFromPossiblyUnqualifiedName(c.input)
if len(c.expected) == 0 {
assert.Error(t, err, c.input)
} else {
assert.NoError(t, err, c.input)
- strings := make([]pullRefStrings, len(res))
- for i, rn := range res {
+ strings := make([]pullRefStrings, len(res.refNames))
+ for i, rn := range res.refNames {
strings[i] = pullRefStrings{
image: rn.image,
srcRef: transports.ImageName(rn.srcRef),