tests: Use EnsureImageExists for image pulling

A previous commit introduced EnsureImageExists, which ensures that a particular image
already exists. It also deduplicates the image pulling code. Some tests missed this
update.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
Claudiu Belu 2021-03-30 18:26:10 +03:00
parent a78bdf22df
commit cabe677369

View File

@ -75,11 +75,7 @@ func TestContainerConsumedStats(t *testing.T) {
sb, sbConfig := PodSandboxConfigWithCleanup(t, "sandbox1", "stats")
testImage := GetImage(ResourceConsumer)
img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig)
require.NoError(t, err)
defer func() {
assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img}))
}()
EnsureImageExists(t, testImage)
t.Logf("Create a container config and run container in a pod")
containerConfig := ContainerConfig(