summaryrefslogtreecommitdiff
path: root/libpod/test_common.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/test_common.go')
-rw-r--r--libpod/test_common.go44
1 files changed, 43 insertions, 1 deletions
diff --git a/libpod/test_common.go b/libpod/test_common.go
index b6188ce80..ad3020b7e 100644
--- a/libpod/test_common.go
+++ b/libpod/test_common.go
@@ -24,7 +24,7 @@ func getTestContainer(id, name, locksDir string) (*Container, error) {
StaticDir: "/does/not/exist/",
LogPath: "/does/not/exist/",
Stdin: true,
- Labels: make(map[string]string),
+ Labels: map[string]string{"a": "b", "c": "d"},
StopSignal: 0,
StopTimeout: 0,
CreatedTime: time.Now(),
@@ -74,6 +74,25 @@ func getTestContainer(id, name, locksDir string) (*Container, error) {
return ctr, nil
}
+// nolint
+func getTestPod(id, name, locksDir string) (*Pod, error) {
+ pod := &Pod{
+ id: id,
+ name: name,
+ labels: map[string]string{"a": "b", "c": "d"},
+ valid: true,
+ }
+
+ lockPath := filepath.Join(locksDir, id)
+ lock, err := storage.GetLockfile(lockPath)
+ if err != nil {
+ return nil, err
+ }
+ pod.lock = lock
+
+ return pod, nil
+}
+
// This horrible hack tests if containers are equal in a way that should handle
// empty arrays being dropped to nil pointers in the spec JSON
// nolint
@@ -114,3 +133,26 @@ func testContainersEqual(a, b *Container) bool {
return reflect.DeepEqual(aStateJSON, bStateJSON)
}
+
+// This tests pod equality
+// We cannot guarantee equality in lockfile objects so we can't simply compare
+// nolint
+func testPodsEqual(a, b *Pod) bool {
+ if a == nil && b == nil {
+ return true
+ } else if a == nil || b == nil {
+ return false
+ }
+
+ if a.id != b.id {
+ return false
+ }
+ if a.name != b.name {
+ return false
+ }
+ if a.valid != b.valid {
+ return false
+ }
+
+ return reflect.DeepEqual(a.labels, b.labels)
+}