summaryrefslogtreecommitdiff
path: root/test/e2e/pod_create_test.go
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2022-04-27 14:58:46 -0600
committerEd Santiago <santiago@redhat.com>2022-04-28 05:41:53 -0600
commitb3f38c31b29b51440edd5913a90019efbced0862 (patch)
tree72749f8e3ddedee0bb882c186a7f3cee08fe5f1c /test/e2e/pod_create_test.go
parent2b8cafc0671fbbd155770f044b8216f050877192 (diff)
downloadpodman-b3f38c31b29b51440edd5913a90019efbced0862.tar.gz
podman-b3f38c31b29b51440edd5913a90019efbced0862.tar.bz2
podman-b3f38c31b29b51440edd5913a90019efbced0862.zip
Ginkgo: use HaveField() for better error checking
This is a very late followup to my ginkgo-improving work of 2021. It has been stuck since December because it requires gomega 1.17, which we've just enabled. This commit is simply a copy-paste of a command I saved in my TODO list many months ago: sed -i -e 's/Expect(\([^ ]\+\)\.\([a-zA-Z0-9]\+\))\.To(Equal(/Expect(\1).To(HaveField(\"\2\", /' test/e2e/*_test.go Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/e2e/pod_create_test.go')
-rw-r--r--test/e2e/pod_create_test.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go
index 8def80213..0c7886a93 100644
--- a/test/e2e/pod_create_test.go
+++ b/test/e2e/pod_create_test.go
@@ -279,7 +279,7 @@ var _ = Describe("Podman pod create", func() {
ctrInspect.WaitWithDefaultTimeout()
Expect(ctrInspect).Should(Exit(0))
ctrJSON := ctrInspect.InspectContainerToJSON()
- Expect(ctrJSON[0].NetworkSettings.IPAddress).To(Equal(ip))
+ Expect(ctrJSON[0].NetworkSettings).To(HaveField("IPAddress", ip))
})
It("podman create pod with IP address and no infra should fail", func() {
@@ -336,7 +336,7 @@ var _ = Describe("Podman pod create", func() {
check := podmanTest.Podman([]string{"pod", "inspect", "abc"})
check.WaitWithDefaultTimeout()
data := check.InspectPodToJSON()
- Expect(data.ID).To(Equal(string(id)))
+ Expect(data).To(HaveField("ID", string(id)))
})
It("podman pod create --replace", func() {
@@ -551,8 +551,8 @@ ENTRYPOINT ["sleep","99999"]
podInspect.WaitWithDefaultTimeout()
Expect(podInspect).Should(Exit(0))
podJSON := podInspect.InspectPodToJSON()
- Expect(podJSON.CPUPeriod).To(Equal(period))
- Expect(podJSON.CPUQuota).To(Equal(quota))
+ Expect(podJSON).To(HaveField("CPUPeriod", period))
+ Expect(podJSON).To(HaveField("CPUQuota", quota))
})
It("podman pod create --cpuset-cpus", func() {
@@ -573,7 +573,7 @@ ENTRYPOINT ["sleep","99999"]
podInspect.WaitWithDefaultTimeout()
Expect(podInspect).Should(Exit(0))
podJSON := podInspect.InspectPodToJSON()
- Expect(podJSON.CPUSetCPUs).To(Equal(in))
+ Expect(podJSON).To(HaveField("CPUSetCPUs", in))
})
It("podman pod create --pid", func() {
@@ -587,7 +587,7 @@ ENTRYPOINT ["sleep","99999"]
podInspect.WaitWithDefaultTimeout()
Expect(podInspect).Should(Exit(0))
podJSON := podInspect.InspectPodToJSON()
- Expect(podJSON.InfraConfig.PidNS).To(Equal(ns))
+ Expect(podJSON.InfraConfig).To(HaveField("PidNS", ns))
podName = "pidPod2"
ns = "pod"
@@ -607,7 +607,7 @@ ENTRYPOINT ["sleep","99999"]
podInspect.WaitWithDefaultTimeout()
Expect(podInspect).Should(Exit(0))
podJSON = podInspect.InspectPodToJSON()
- Expect(podJSON.InfraConfig.PidNS).To(Equal("host"))
+ Expect(podJSON.InfraConfig).To(HaveField("PidNS", "host"))
podName = "pidPod4"
ns = "private"
@@ -620,7 +620,7 @@ ENTRYPOINT ["sleep","99999"]
podInspect.WaitWithDefaultTimeout()
Expect(podInspect).Should(Exit(0))
podJSON = podInspect.InspectPodToJSON()
- Expect(podJSON.InfraConfig.PidNS).To(Equal("private"))
+ Expect(podJSON.InfraConfig).To(HaveField("PidNS", "private"))
podName = "pidPod5"
ns = "container:randomfakeid"
@@ -856,7 +856,7 @@ ENTRYPOINT ["sleep","99999"]
podInspect.WaitWithDefaultTimeout()
Expect(podInspect).Should(Exit(0))
data := podInspect.InspectPodToJSON()
- Expect(data.Mounts[0].Name).To(Equal(volName))
+ Expect(data.Mounts[0]).To(HaveField("Name", volName))
ctrName := "testCtr"
ctrCreate := podmanTest.Podman([]string{"create", "--pod", podName, "--name", ctrName, ALPINE})
ctrCreate.WaitWithDefaultTimeout()
@@ -865,7 +865,7 @@ ENTRYPOINT ["sleep","99999"]
ctrInspect.WaitWithDefaultTimeout()
Expect(ctrInspect).Should(Exit(0))
ctrData := ctrInspect.InspectContainerToJSON()
- Expect(ctrData[0].Mounts[0].Name).To(Equal(volName))
+ Expect(ctrData[0].Mounts[0]).To(HaveField("Name", volName))
ctr2 := podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "sh", "-c", "echo hello >> " + "/tmp1/test"})
ctr2.WaitWithDefaultTimeout()
@@ -934,7 +934,7 @@ ENTRYPOINT ["sleep","99999"]
ctrInspect.WaitWithDefaultTimeout()
Expect(ctrInspect).Should(Exit(0))
data := ctrInspect.InspectContainerToJSON()
- Expect(data[0].Mounts[0].Name).To(Equal(volName))
+ Expect(data[0].Mounts[0]).To(HaveField("Name", volName))
podName := "testPod"
podCreate := podmanTest.Podman([]string{"pod", "create", "--volumes-from", ctrName, "--name", podName})
podCreate.WaitWithDefaultTimeout()
@@ -943,7 +943,7 @@ ENTRYPOINT ["sleep","99999"]
podInspect.WaitWithDefaultTimeout()
Expect(podInspect).Should(Exit(0))
podData := podInspect.InspectPodToJSON()
- Expect(podData.Mounts[0].Name).To(Equal(volName))
+ Expect(podData.Mounts[0]).To(HaveField("Name", volName))
ctr2 := podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "sh", "-c", "echo hello >> " + "/tmp1/test"})
ctr2.WaitWithDefaultTimeout()
@@ -986,7 +986,7 @@ ENTRYPOINT ["sleep","99999"]
Expect(ctrCreate).Should(Exit(0))
ctrInspect := podmanTest.InspectContainer(ctrCreate.OutputToString())
- Expect(ctrInspect[0].HostConfig.SecurityOpt).To(Equal([]string{"label=type:spc_t", "seccomp=unconfined"}))
+ Expect(ctrInspect[0].HostConfig).To(HaveField("SecurityOpt", []string{"label=type:spc_t", "seccomp=unconfined"}))
podCreate = podmanTest.Podman([]string{"pod", "create", "--security-opt", "label=disable"})
podCreate.WaitWithDefaultTimeout()
@@ -1012,7 +1012,7 @@ ENTRYPOINT ["sleep","99999"]
Expect(ctrCreate).Should(Exit(0))
ctrInspect := podmanTest.InspectContainer(ctrCreate.OutputToString())
- Expect(ctrInspect[0].HostConfig.SecurityOpt).To(Equal([]string{"seccomp=unconfined"}))
+ Expect(ctrInspect[0].HostConfig).To(HaveField("SecurityOpt", []string{"seccomp=unconfined"}))
})
It("podman pod create --security-opt apparmor test", func() {
@@ -1028,7 +1028,7 @@ ENTRYPOINT ["sleep","99999"]
Expect(ctrCreate).Should(Exit(0))
inspect := podmanTest.InspectContainer(ctrCreate.OutputToString())
- Expect(inspect[0].AppArmorProfile).To(Equal(apparmor.Profile))
+ Expect(inspect[0]).To(HaveField("AppArmorProfile", apparmor.Profile))
})
@@ -1090,7 +1090,7 @@ ENTRYPOINT ["sleep","99999"]
if podmanTest.CgroupManager == "cgroupfs" || !rootless.IsRootless() {
Expect(inspect[0].HostConfig.CgroupParent).To(HaveLen(0))
} else if podmanTest.CgroupManager == "systemd" {
- Expect(inspect[0].HostConfig.CgroupParent).To(Equal("user.slice"))
+ Expect(inspect[0].HostConfig).To(HaveField("CgroupParent", "user.slice"))
}
podCreate2 := podmanTest.Podman([]string{"pod", "create", "--share", "cgroup,ipc,net,uts", "--share-parent=false", "--infra-name", "cgroupCtr"})