diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-02-14 17:52:49 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-02-21 10:51:42 -0500 |
commit | a3dbb7a837f0c6fe9e12aec6da3778759632f7d1 (patch) | |
tree | e532adb39652b5fa3d1263880e2587285ae4614e /libpod/state_test.go | |
parent | 7fdd20ae5a1ced1faceab9cb0a6e553343911a0b (diff) | |
download | podman-a3dbb7a837f0c6fe9e12aec6da3778759632f7d1.tar.gz podman-a3dbb7a837f0c6fe9e12aec6da3778759632f7d1.tar.bz2 podman-a3dbb7a837f0c6fe9e12aec6da3778759632f7d1.zip |
Add ability to rewrite pod configs in the database
Necessary for rewriting lock IDs as part of renumber.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/state_test.go')
-rw-r--r-- | libpod/state_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libpod/state_test.go b/libpod/state_test.go index dd03903ac..be68a2d69 100644 --- a/libpod/state_test.go +++ b/libpod/state_test.go @@ -1334,6 +1334,42 @@ func TestRewriteContainerConfigRewritesConfig(t *testing.T) { }) } +func TestRewritePodConfigDoesNotExist(t *testing.T) { + runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + err := state.RewritePodConfig(&Pod{}, &PodConfig{}) + assert.Error(t, err) + }) +} + +func TestRewritePodConfigNotInState(t *testing.T) { + runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + testPod, err := getTestPod1(manager) + assert.NoError(t, err) + err = state.RewritePodConfig(testPod, &PodConfig{}) + assert.Error(t, err) + }) +} + +func TestRewritePodConfigRewritesConfig(t *testing.T) { + runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + testPod, err := getTestPod1(manager) + assert.NoError(t, err) + + err = state.AddPod(testPod) + assert.NoError(t, err) + + testPod.config.CgroupParent = "/another_cgroup_parent" + + err = state.RewritePodConfig(testPod, testPod.config) + assert.NoError(t, err) + + testPodFromState, err := state.Pod(testPod.ID()) + assert.NoError(t, err) + + testPodsEqual(t, testPodFromState, testPod, true) + }) +} + func TestGetPodDoesNotExist(t *testing.T) { runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { _, err := state.Pod("doesnotexist") |