summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-01-16 13:27:39 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-17 15:26:43 +0000
commit54e258bfde8f6164abf3cd0e6d8d18b1643cc91d (patch)
tree55092a127fff8cf03dd707245b250f51209f595d
parentaa34b86ae601398a3abac0ee70ed9a4ea96187c3 (diff)
downloadpodman-54e258bfde8f6164abf3cd0e6d8d18b1643cc91d.tar.gz
podman-54e258bfde8f6164abf3cd0e6d8d18b1643cc91d.tar.bz2
podman-54e258bfde8f6164abf3cd0e6d8d18b1643cc91d.zip
Convert remaining state tests to new style
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #229 Approved by: rhatdan
-rw-r--r--libpod/state_test.go37
1 files changed, 16 insertions, 21 deletions
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)