From 86491efea0fcf5ab9e76668b1dadf004a74c62e0 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Sat, 28 Jul 2018 06:02:49 +0200 Subject: Introduce struct pullGoalNames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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č Closes: #1176 Approved by: rhatdan --- libpod/image/pull_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'libpod/image/pull_test.go') 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), -- cgit v1.2.3-54-g00ecf