tests: Refactors PodSandbox creation

Most of the tests creating and using Pod Sandboxes in the same way. We can create
a common function that will do that for us, so we can have less duplicated code,
and make it easier to add new tests in the future.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
Claudiu Belu
2021-03-30 18:16:20 +03:00
parent ada96ec192
commit a78bdf22df
17 changed files with 56 additions and 175 deletions

View File

@@ -77,13 +77,7 @@ func TestImageLoad(t *testing.T) {
require.Equal(t, []string{loadedImage}, img.RepoTags)
t.Logf("create a container with the loaded image")
sbConfig := PodSandboxConfig("sandbox", Randomize("image-load"))
sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
require.NoError(t, err)
defer func() {
assert.NoError(t, runtimeService.StopPodSandbox(sb))
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
}()
sb, sbConfig := PodSandboxConfigWithCleanup(t, "sandbox", Randomize("image-load"))
containerConfig := ContainerConfig(
"container",
testImage,