summaryrefslogtreecommitdiff
path: root/libpod/state_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/state_test.go')
-rw-r--r--libpod/state_test.go137
1 files changed, 91 insertions, 46 deletions
diff --git a/libpod/state_test.go b/libpod/state_test.go
index d4a4149f9..39937d8e4 100644
--- a/libpod/state_test.go
+++ b/libpod/state_test.go
@@ -350,7 +350,8 @@ func TestAddCtrSameNamespaceSucceeds(t *testing.T) {
testCtr.config.Namespace = "test1"
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
err = state.AddContainer(testCtr)
assert.NoError(t, err)
@@ -369,12 +370,14 @@ func TestAddCtrDifferentNamespaceFails(t *testing.T) {
testCtr.config.Namespace = "test1"
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.AddContainer(testCtr)
assert.Error(t, err)
- state.SetNamespace("")
+ err = state.SetNamespace("")
+ assert.NoError(t, err)
ctrs, err := state.AllContainers()
assert.NoError(t, err)
@@ -406,7 +409,8 @@ func TestGetContainerInDifferentNamespaceFails(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
_, err = state.Container(testCtr.ID())
assert.Error(t, err)
@@ -423,7 +427,8 @@ func TestGetContainerInSameNamespaceSucceeds(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
ctr, err := state.Container(testCtr.ID())
assert.NoError(t, err)
@@ -586,7 +591,8 @@ func TestLookupCtrInSameNamespaceSucceeds(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
ctr, err := state.LookupContainer(testCtr.ID())
assert.NoError(t, err)
@@ -608,7 +614,8 @@ func TestLookupCtrInDifferentNamespaceFails(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
_, err = state.LookupContainer(testCtr.ID())
assert.Error(t, err)
@@ -633,7 +640,8 @@ func TestLookupContainerMatchInDifferentNamespaceSucceeds(t *testing.T) {
err = state.AddContainer(testCtr2)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
ctr, err := state.LookupContainer("000")
assert.NoError(t, err)
@@ -698,7 +706,8 @@ func TestHasContainerSameNamespaceIsTrue(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
exists, err := state.HasContainer(testCtr.ID())
assert.NoError(t, err)
@@ -716,7 +725,8 @@ func TestHasContainerDifferentNamespaceIsFalse(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
exists, err := state.HasContainer(testCtr.ID())
assert.NoError(t, err)
@@ -759,7 +769,8 @@ func TestSaveAndUpdateContainerSameNamespaceSucceeds(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
retrievedCtr, err := state.Container(testCtr.ID())
assert.NoError(t, err)
@@ -806,7 +817,8 @@ func TestUpdateContainerNotInNamespaceReturnsError(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.UpdateContainer(testCtr)
assert.Error(t, err)
@@ -841,7 +853,8 @@ func TestSaveContainerNotInNamespaceReturnsError(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.SaveContainer(testCtr)
assert.Error(t, err)
@@ -894,12 +907,14 @@ func TestRemoveContainerNotInNamespaceFails(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 1, len(ctrs))
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.RemoveContainer(testCtr)
assert.Error(t, err)
- state.SetNamespace("")
+ err = state.SetNamespace("")
+ assert.NoError(t, err)
ctrs2, err := state.AllContainers()
assert.NoError(t, err)
@@ -960,7 +975,8 @@ func TestGetAllContainersNoContainerInNamespace(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
ctrs, err := state.AllContainers()
assert.NoError(t, err)
@@ -984,7 +1000,8 @@ func TestGetContainerOneContainerInNamespace(t *testing.T) {
err = state.AddContainer(testCtr2)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
ctrs, err := state.AllContainers()
assert.NoError(t, err)
@@ -1020,7 +1037,8 @@ func TestContainerInUseCtrNotInNamespace(t *testing.T) {
err = state.AddContainer(testCtr)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
_, err = state.ContainerInUse(testCtr)
assert.Error(t, err)
@@ -1497,7 +1515,8 @@ func TestGetPodInNamespaceSucceeds(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
statePod, err := state.Pod(testPod.ID())
assert.NoError(t, err)
@@ -1516,7 +1535,8 @@ func TestGetPodPodNotInNamespaceFails(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
_, err = state.Pod(testPod.ID())
assert.Error(t, err)
@@ -1637,7 +1657,8 @@ func TestLookupPodInSameNamespaceSucceeds(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
statePod, err := state.LookupPod(testPod.ID())
assert.NoError(t, err)
@@ -1656,7 +1677,8 @@ func TestLookupPodInDifferentNamespaceFails(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
_, err = state.LookupPod(testPod.ID())
assert.Error(t, err)
@@ -1681,7 +1703,8 @@ func TestLookupPodOneInDifferentNamespaceFindsRightPod(t *testing.T) {
err = state.AddPod(testPod2)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
pod, err := state.LookupPod(strings.Repeat("1", 5))
assert.NoError(t, err)
@@ -1757,7 +1780,8 @@ func TestHasPodSameNamespaceSucceeds(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
exist, err := state.HasPod(testPod.ID())
assert.NoError(t, err)
@@ -1775,7 +1799,8 @@ func TestHasPodDifferentNamespaceFails(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
exist, err := state.HasPod(testPod.ID())
assert.NoError(t, err)
@@ -1913,7 +1938,8 @@ func TestAddPodSameNamespaceSucceeds(t *testing.T) {
testPod.config.Namespace = "test1"
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
err = state.AddPod(testPod)
assert.NoError(t, err)
@@ -1933,12 +1959,14 @@ func TestAddPodDifferentNamespaceFails(t *testing.T) {
testPod.config.Namespace = "test1"
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.AddPod(testPod)
assert.Error(t, err)
- state.SetNamespace("")
+ err = state.SetNamespace("")
+ assert.NoError(t, err)
allPods, err := state.AllPods()
assert.NoError(t, err)
@@ -2067,12 +2095,14 @@ func TestRemovePodNotInNamespaceFails(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.RemovePod(testPod)
assert.Error(t, err)
- state.SetNamespace("")
+ err = state.SetNamespace("")
+ assert.NoError(t, err)
allPods, err := state.AllPods()
assert.NoError(t, err)
@@ -2152,7 +2182,8 @@ func TestAllPodsPodInDifferentNamespaces(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
allPods, err := state.AllPods()
assert.NoError(t, err)
@@ -2178,7 +2209,8 @@ func TestAllPodsOnePodInDifferentNamespace(t *testing.T) {
err = state.AddPod(testPod2)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
allPods, err := state.AllPods()
assert.NoError(t, err)
@@ -2274,7 +2306,8 @@ func TestPodHasContainerPodNotInNamespaceFails(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
_, err = state.PodHasContainer(testPod, strings.Repeat("2", 32))
assert.Error(t, err)
@@ -2393,7 +2426,8 @@ func TestPodContainerByIDPodNotInNamespace(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
_, err = state.PodContainersByID(testPod)
assert.Error(t, err)
@@ -2513,7 +2547,8 @@ func TestPodContainersPodNotInNamespace(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
_, err = state.PodContainers(testPod)
assert.Error(t, err)
@@ -2686,7 +2721,8 @@ func TestRemoveContainersNotInNamespace(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.RemovePodContainers(testPod)
assert.Error(t, err)
@@ -3229,7 +3265,8 @@ func TestAddCtrToPodSameNamespaceSucceeds(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
err = state.AddContainerToPod(testPod, testCtr)
assert.NoError(t, err)
@@ -3253,15 +3290,17 @@ func TestAddCtrToPodDifferentNamespaceFails(t *testing.T) {
testPod.config.Namespace = "test1"
testCtr.config.Pod = testPod.ID()
- state.AddPod(testPod)
+ err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.AddContainerToPod(testPod, testCtr)
assert.Error(t, err)
- state.SetNamespace("")
+ err = state.SetNamespace("")
+ assert.NoError(t, err)
ctrs, err := state.AllContainers()
assert.NoError(t, err)
@@ -3461,7 +3500,8 @@ func TestRemoveContainerFromPodSameNamespaceSucceeds(t *testing.T) {
err = state.AddContainerToPod(testPod, testCtr)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
err = state.RemoveContainerFromPod(testPod, testCtr)
assert.NoError(t, err)
@@ -3495,12 +3535,14 @@ func TestRemoveContainerFromPodDifferentNamespaceFails(t *testing.T) {
err = state.AddContainerToPod(testPod, testCtr)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.RemoveContainerFromPod(testPod, testCtr)
assert.Error(t, err)
- state.SetNamespace("")
+ err = state.SetNamespace("")
+ assert.NoError(t, err)
ctrs, err := state.PodContainers(testPod)
assert.NoError(t, err)
@@ -3539,7 +3581,8 @@ func TestUpdatePodNotInNamespaceFails(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.UpdatePod(testPod)
assert.Error(t, err)
@@ -3573,7 +3616,8 @@ func TestSavePodNotInNamespaceFails(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test2")
+ err = state.SetNamespace("test2")
+ assert.NoError(t, err)
err = state.SavePod(testPod)
assert.Error(t, err)
@@ -3615,7 +3659,8 @@ func TestSaveAndUpdatePodSameNamespace(t *testing.T) {
err = state.AddPod(testPod)
assert.NoError(t, err)
- state.SetNamespace("test1")
+ err = state.SetNamespace("test1")
+ assert.NoError(t, err)
statePod, err := state.Pod(testPod.ID())
assert.NoError(t, err)