diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-01-04 16:04:46 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-01-17 15:26:43 +0000 |
commit | 67b6c132d83b94d20c9ef204c8dcba3de5581f60 (patch) | |
tree | bccb7d4174a53899f4931c6eac55d93dcd7602f8 /libpod/in_memory_state.go | |
parent | 65d643caeb31364b59612f0f91be90894c65d703 (diff) | |
download | podman-67b6c132d83b94d20c9ef204c8dcba3de5581f60.tar.gz podman-67b6c132d83b94d20c9ef204c8dcba3de5581f60.tar.bz2 podman-67b6c132d83b94d20c9ef204c8dcba3de5581f60.zip |
Modify unit tests for state to run on all state implementations
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #229
Approved by: rhatdan
Diffstat (limited to 'libpod/in_memory_state.go')
-rw-r--r-- | libpod/in_memory_state.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go index 244a1ab25..19d14366c 100644 --- a/libpod/in_memory_state.go +++ b/libpod/in_memory_state.go @@ -182,6 +182,18 @@ func (s *InMemoryState) RemoveContainer(ctr *Container) error { // As all state is in-memory, no update will be required // As such this is a no-op func (s *InMemoryState) UpdateContainer(ctr *Container) error { + // If the container is invalid, return error + if !ctr.valid { + return errors.Wrapf(ErrCtrRemoved, "container with ID %s is not valid", ctr.ID()) + } + + // If the container does not exist, return error + _, ok := s.containers[ctr.ID()] + if !ok { + ctr.valid = false + return errors.Wrapf(ErrNoSuchCtr, "container with ID %s not found in state", ctr.ID()) + } + return nil } @@ -190,6 +202,18 @@ func (s *InMemoryState) UpdateContainer(ctr *Container) error { // are made // As such this is a no-op func (s *InMemoryState) SaveContainer(ctr *Container) error { + // If the container is invalid, return error + if !ctr.valid { + return errors.Wrapf(ErrCtrRemoved, "container with ID %s is not valid", ctr.ID()) + } + + // If the container does not exist, return error + _, ok := s.containers[ctr.ID()] + if !ok { + ctr.valid = false + return errors.Wrapf(ErrNoSuchCtr, "container with ID %s not found in state", ctr.ID()) + } + return nil } |