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:
@@ -32,16 +32,9 @@ func TestRunPodSandboxWithoutMetadata(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateContainerWithoutMetadata(t *testing.T) {
|
||||
sbConfig := PodSandboxConfig("sandbox", "container-create")
|
||||
sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
// Make sure the sandbox is cleaned up in any case.
|
||||
runtimeService.StopPodSandbox(sb)
|
||||
runtimeService.RemovePodSandbox(sb)
|
||||
}()
|
||||
sb, sbConfig := PodSandboxConfigWithCleanup(t, "sandbox", "container-create")
|
||||
config := &runtime.ContainerConfig{}
|
||||
_, err = runtimeService.CreateContainer(sb, config, sbConfig)
|
||||
_, err := runtimeService.CreateContainer(sb, config, sbConfig)
|
||||
require.Error(t, err)
|
||||
_, err = runtimeService.Status()
|
||||
require.NoError(t, err)
|
||||
|
Reference in New Issue
Block a user