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:
@@ -39,13 +39,7 @@ func TestVolumeCopyUp(t *testing.T) {
|
||||
)
|
||||
|
||||
t.Logf("Create a sandbox")
|
||||
sbConfig := PodSandboxConfig("sandbox", "volume-copy-up")
|
||||
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", "volume-copy-up")
|
||||
|
||||
EnsureImageExists(t, testImage)
|
||||
|
||||
@@ -102,13 +96,7 @@ func TestVolumeOwnership(t *testing.T) {
|
||||
)
|
||||
|
||||
t.Logf("Create a sandbox")
|
||||
sbConfig := PodSandboxConfig("sandbox", "volume-ownership")
|
||||
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", "volume-ownership")
|
||||
|
||||
EnsureImageExists(t, testImage)
|
||||
|
||||
|
Reference in New Issue
Block a user