diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-02-14 15:53:24 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-02-21 10:51:42 -0500 |
commit | 84feff2e06e9c3dd504be918f8dcf0b0a434a941 (patch) | |
tree | 52d809c77c5c920f2a948880333dee5c157134d8 /libpod/state_test.go | |
parent | 28d6eeb57a46b8df8960cff6bf6748c4611b61ef (diff) | |
download | podman-84feff2e06e9c3dd504be918f8dcf0b0a434a941.tar.gz podman-84feff2e06e9c3dd504be918f8dcf0b0a434a941.tar.bz2 podman-84feff2e06e9c3dd504be918f8dcf0b0a434a941.zip |
Add a function for overwriting container config
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 4bd00ab55..dd03903ac 100644 --- a/libpod/state_test.go +++ b/libpod/state_test.go @@ -1298,6 +1298,42 @@ func TestCannotUseBadIDAsGenericDependency(t *testing.T) { }) } +func TestRewriteContainerConfigDoesNotExist(t *testing.T) { + runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + err := state.RewriteContainerConfig(&Container{}, &ContainerConfig{}) + assert.Error(t, err) + }) +} + +func TestRewriteContainerConfigNotInState(t *testing.T) { + runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + testCtr, err := getTestCtr1(manager) + assert.NoError(t, err) + err = state.RewriteContainerConfig(testCtr, &ContainerConfig{}) + assert.Error(t, err) + }) +} + +func TestRewriteContainerConfigRewritesConfig(t *testing.T) { + runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + testCtr, err := getTestCtr1(manager) + assert.NoError(t, err) + + err = state.AddContainer(testCtr) + assert.NoError(t, err) + + testCtr.config.LogPath = "/another/path/" + + err = state.RewriteContainerConfig(testCtr, testCtr.config) + assert.NoError(t, err) + + testCtrFromState, err := state.Container(testCtr.ID()) + assert.NoError(t, err) + + testContainersEqual(t, testCtrFromState, testCtr, true) + }) +} + func TestGetPodDoesNotExist(t *testing.T) { runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { _, err := state.Pod("doesnotexist") |