From 54e258bfde8f6164abf3cd0e6d8d18b1643cc91d Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 16 Jan 2018 13:27:39 -0500 Subject: Convert remaining state tests to new style Signed-off-by: Matthew Heon Closes: #229 Approved by: rhatdan --- libpod/state_test.go | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'libpod/state_test.go') diff --git a/libpod/state_test.go b/libpod/state_test.go index a1a4e23e1..0a18c988d 100644 --- a/libpod/state_test.go +++ b/libpod/state_test.go @@ -513,21 +513,19 @@ func getAllContainersTwoContainers(t *testing.T, state State, lockPath string) { } func TestContainerInUseInvalidContainer(t *testing.T) { - state, path, _, err := getEmptyState() - assert.NoError(t, err) - defer os.RemoveAll(path) - defer state.Close() + runForAllStates(t, "TestContainerInUseInvalidContainer", containerInUseInvalidContainer) +} - _, err = state.ContainerInUse(&Container{}) +func containerInUseInvalidContainer(t *testing.T, state State, lockPath string) { + _, err := state.ContainerInUse(&Container{}) assert.Error(t, err) } func TestContainerInUseOneContainer(t *testing.T) { - state, path, lockPath, err := getEmptyState() - assert.NoError(t, err) - defer os.RemoveAll(path) - defer state.Close() + runForAllStates(t, "TestContainerInUseOneContainer", containerInUseOneContainer) +} +func containerInUseOneContainer(t *testing.T, state State, lockPath string) { testCtr1, err := getTestContainer("11111111111111111111111111111111", "test1", lockPath) assert.NoError(t, err) testCtr2, err := getTestContainer("22222222222222222222222222222222", "test2", lockPath) @@ -548,11 +546,10 @@ func TestContainerInUseOneContainer(t *testing.T) { } func TestContainerInUseTwoContainers(t *testing.T) { - state, path, lockPath, err := getEmptyState() - assert.NoError(t, err) - defer os.RemoveAll(path) - defer state.Close() + runForAllStates(t, "TestContainerInUseTwoContainers", containerInUseTwoContainers) +} +func containerInUseTwoContainers(t *testing.T, state State, lockPath string) { testCtr1, err := getTestContainer("11111111111111111111111111111111", "test1", lockPath) assert.NoError(t, err) testCtr2, err := getTestContainer("22222222222222222222222222222222", "test2", lockPath) @@ -578,11 +575,10 @@ func TestContainerInUseTwoContainers(t *testing.T) { } func TestCannotRemoveContainerWithDependency(t *testing.T) { - state, path, lockPath, err := getEmptyState() - assert.NoError(t, err) - defer os.RemoveAll(path) - defer state.Close() + runForAllStates(t, "TestCannotRemoveContainerWithDependency", cannotRemoveContainerWithDependency) +} +func cannotRemoveContainerWithDependency(t *testing.T, state State, lockPath string) { testCtr1, err := getTestContainer("11111111111111111111111111111111", "test1", lockPath) assert.NoError(t, err) testCtr2, err := getTestContainer("22222222222222222222222222222222", "test2", lockPath) @@ -601,11 +597,10 @@ func TestCannotRemoveContainerWithDependency(t *testing.T) { } func TestCanRemoveContainerAfterDependencyRemoved(t *testing.T) { - state, path, lockPath, err := getEmptyState() - assert.NoError(t, err) - defer os.RemoveAll(path) - defer state.Close() + runForAllStates(t, "TestCanRemoveContainerAfterDependencyRemoved", canRemoveContainerAfterDependencyRemoved) +} +func canRemoveContainerAfterDependencyRemoved(t *testing.T, state State, lockPath string) { testCtr1, err := getTestContainer("11111111111111111111111111111111", "test1", lockPath) assert.NoError(t, err) testCtr2, err := getTestContainer("22222222222222222222222222222222", "test2", lockPath) -- cgit v1.2.3-54-g00ecf