mirror of
https://github.com/containers/podman.git
synced 2025-06-19 16:33:24 +08:00
e2e tests: more cleanup of BeTrue()s
Write a BeValidJSON() matcher, and replace IsJSONOutputValid(): sed -i -e 's/Expect(\(.*\)\.IsJSONOutputValid()).To(BeTrue())/Expect(\1.OutputToString())\.To(BeValidJSON())/' test/e2e/*_test.go (Plus a few manual tweaks) Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@ -388,13 +388,10 @@ subdir**`
|
|||||||
session := podmanTest.Podman([]string{"build", "-t", "test", "."})
|
session := podmanTest.Podman([]string{"build", "-t", "test", "."})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
ok, _ := session.GrepString("/testfilter/dummy1")
|
output := session.OutputToString()
|
||||||
Expect(ok).NotTo(BeTrue())
|
Expect(output).To(ContainSubstring("/testfilter/dummy2"))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("/testfilter/dummy2"))
|
Expect(output).NotTo(ContainSubstring("/testfilter/dummy1"))
|
||||||
ok, _ = session.GrepString("/testfilter/subdir")
|
Expect(output).NotTo(ContainSubstring("/testfilter/subdir"))
|
||||||
Expect(ok).NotTo(BeTrue()) //.dockerignore filters both subdir and inside subdir
|
|
||||||
ok, _ = session.GrepString("/testfilter/subdir/dummy3")
|
|
||||||
Expect(ok).NotTo(BeTrue())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman remote test context dir contains empty dirs and symlinks", func() {
|
It("podman remote test context dir contains empty dirs and symlinks", func() {
|
||||||
|
@ -102,7 +102,7 @@ var _ = Describe("Podman checkpoint", func() {
|
|||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
inspectOut := inspect.InspectContainerToJSON()
|
inspectOut := inspect.InspectContainerToJSON()
|
||||||
Expect(inspectOut[0].State.Checkpointed).To(BeTrue())
|
Expect(inspectOut[0].State.Checkpointed).To(BeTrue(), ".State.Checkpointed")
|
||||||
|
|
||||||
result = podmanTest.Podman([]string{"container", "restore", cid})
|
result = podmanTest.Podman([]string{"container", "restore", cid})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
|
@ -225,7 +225,7 @@ var _ = Describe("Podman commit", func() {
|
|||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
image := inspect.InspectImageJSON()
|
image := inspect.InspectImageJSON()
|
||||||
_, ok := image[0].Config.Volumes["/foo"]
|
_, ok := image[0].Config.Volumes["/foo"]
|
||||||
Expect(ok).To(BeTrue())
|
Expect(ok).To(BeTrue(), ".Config.Volumes[/foo]")
|
||||||
|
|
||||||
r := podmanTest.Podman([]string{"run", "newimage"})
|
r := podmanTest.Podman([]string{"run", "newimage"})
|
||||||
r.WaitWithDefaultTimeout()
|
r.WaitWithDefaultTimeout()
|
||||||
@ -250,7 +250,7 @@ var _ = Describe("Podman commit", func() {
|
|||||||
for _, v := range image[0].Config.Env {
|
for _, v := range image[0].Config.Env {
|
||||||
envMap[v] = true
|
envMap[v] = true
|
||||||
}
|
}
|
||||||
Expect(envMap["TEST=1=1-01=9.01"]).To(BeTrue())
|
Expect(envMap["TEST=1=1-01=9.01"]).To(BeTrue(), "envMap[TEST=1=1-01=9.01]")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman commit container and print id to external file", func() {
|
It("podman commit container and print id to external file", func() {
|
||||||
|
@ -108,7 +108,7 @@ var _ = Describe("Podman create", func() {
|
|||||||
check.WaitWithDefaultTimeout()
|
check.WaitWithDefaultTimeout()
|
||||||
data := check.InspectContainerToJSON()
|
data := check.InspectContainerToJSON()
|
||||||
value, ok := data[0].Config.Annotations["HELLO"]
|
value, ok := data[0].Config.Annotations["HELLO"]
|
||||||
Expect(ok).To(BeTrue())
|
Expect(ok).To(BeTrue(), ".Config.Annotations[HELLO]")
|
||||||
Expect(value).To(Equal("WORLD"))
|
Expect(value).To(Equal("WORLD"))
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ var _ = Describe("Podman create", func() {
|
|||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("/create/test ro"))
|
Expect(session.OutputToString()).To(ContainSubstring("/create/test ro"))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"create", "--log-driver", "k8s-file", "--name", "test_shared", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test,shared", mountPath), ALPINE, "grep", "/create/test", "/proc/self/mountinfo"})
|
session = podmanTest.Podman([]string{"create", "--log-driver", "k8s-file", "--name", "test_shared", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test,shared", mountPath), ALPINE, "awk", `$5 == "/create/test" { print $6 " " $7}`, "/proc/self/mountinfo"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
session = podmanTest.Podman([]string{"start", "test_shared"})
|
session = podmanTest.Podman([]string{"start", "test_shared"})
|
||||||
@ -211,10 +211,8 @@ var _ = Describe("Podman create", func() {
|
|||||||
session = podmanTest.Podman([]string{"logs", "test_shared"})
|
session = podmanTest.Podman([]string{"logs", "test_shared"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
found, matches := session.GrepString("/create/test")
|
Expect(session.OutputToString()).To(ContainSubstring("rw"))
|
||||||
Expect(found).Should(BeTrue())
|
Expect(session.OutputToString()).To(ContainSubstring("shared"))
|
||||||
Expect(matches[0]).To(ContainSubstring("rw"))
|
|
||||||
Expect(matches[0]).To(ContainSubstring("shared"))
|
|
||||||
|
|
||||||
mountPath = filepath.Join(podmanTest.TempDir, "scratchpad")
|
mountPath = filepath.Join(podmanTest.TempDir, "scratchpad")
|
||||||
os.Mkdir(mountPath, 0755)
|
os.Mkdir(mountPath, 0755)
|
||||||
@ -263,7 +261,7 @@ var _ = Describe("Podman create", func() {
|
|||||||
session = podmanTest.Podman([]string{"pod", "inspect", podName})
|
session = podmanTest.Podman([]string{"pod", "inspect", podName})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
podData := session.InspectPodToJSON()
|
podData := session.InspectPodToJSON()
|
||||||
|
|
||||||
// Finally we can create a container with --pod-id-file and do
|
// Finally we can create a container with --pod-id-file and do
|
||||||
@ -386,12 +384,12 @@ var _ = Describe("Podman create", func() {
|
|||||||
inspect := podmanTest.Podman([]string{"inspect", ctrName})
|
inspect := podmanTest.Podman([]string{"inspect", ctrName})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
data := inspect.InspectContainerToJSON()
|
data := inspect.InspectContainerToJSON()
|
||||||
Expect(len(data)).To(Equal(1))
|
Expect(len(data)).To(Equal(1), "len(InspectContainerToJSON)")
|
||||||
Expect(len(data[0].Config.Labels)).To(Equal(2))
|
Expect(len(data[0].Config.Labels)).To(Equal(2))
|
||||||
_, ok1 := data[0].Config.Labels["TESTKEY1"]
|
_, ok1 := data[0].Config.Labels["TESTKEY1"]
|
||||||
Expect(ok1).To(BeTrue())
|
Expect(ok1).To(BeTrue(), ".Config.Labels[TESTKEY1]")
|
||||||
_, ok2 := data[0].Config.Labels["TESTKEY2"]
|
_, ok2 := data[0].Config.Labels["TESTKEY2"]
|
||||||
Expect(ok2).To(BeTrue())
|
Expect(ok2).To(BeTrue(), ".Config.Labels[TESTKEY2]")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman create with set label", func() {
|
It("podman create with set label", func() {
|
||||||
@ -407,10 +405,10 @@ var _ = Describe("Podman create", func() {
|
|||||||
Expect(len(data)).To(Equal(1))
|
Expect(len(data)).To(Equal(1))
|
||||||
Expect(len(data[0].Config.Labels)).To(Equal(2))
|
Expect(len(data[0].Config.Labels)).To(Equal(2))
|
||||||
val1, ok1 := data[0].Config.Labels["TESTKEY1"]
|
val1, ok1 := data[0].Config.Labels["TESTKEY1"]
|
||||||
Expect(ok1).To(BeTrue())
|
Expect(ok1).To(BeTrue(), ".Config.Labels[TESTKEY1]")
|
||||||
Expect(val1).To(Equal("value1"))
|
Expect(val1).To(Equal("value1"))
|
||||||
val2, ok2 := data[0].Config.Labels["TESTKEY2"]
|
val2, ok2 := data[0].Config.Labels["TESTKEY2"]
|
||||||
Expect(ok2).To(BeTrue())
|
Expect(ok2).To(BeTrue(), ".Config.Labels[TESTKEY2]")
|
||||||
Expect(val2).To(Equal("bar"))
|
Expect(val2).To(Equal("bar"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ var _ = Describe("Podman diff", func() {
|
|||||||
session := podmanTest.Podman([]string{"diff", "--format=json", ALPINE})
|
session := podmanTest.Podman([]string{"diff", "--format=json", ALPINE})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman diff container and committed image", func() {
|
It("podman diff container and committed image", func() {
|
||||||
|
@ -607,7 +607,7 @@ var _ = Describe("Podman generate kube", func() {
|
|||||||
err = yaml.Unmarshal(b, pod)
|
err = yaml.Unmarshal(b, pod)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
val, found := pod.Annotations[define.BindMountPrefix+vol1]
|
val, found := pod.Annotations[define.BindMountPrefix+vol1]
|
||||||
Expect(found).To(BeTrue())
|
Expect(found).To(BeTrue(), "pod.Annotations["+vol1+"]")
|
||||||
Expect(val).To(HaveSuffix("z"))
|
Expect(val).To(HaveSuffix("z"))
|
||||||
|
|
||||||
rm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", "test1"})
|
rm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", "test1"})
|
||||||
|
@ -420,7 +420,7 @@ var _ = Describe("Podman generate systemd", func() {
|
|||||||
session := podmanTest.Podman([]string{"generate", "systemd", "--format", "json", "foo"})
|
session := podmanTest.Podman([]string{"generate", "systemd", "--format", "json", "foo"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman generate systemd --new create command with double curly braces", func() {
|
It("podman generate systemd --new create command with double curly braces", func() {
|
||||||
|
@ -89,6 +89,6 @@ var _ = Describe("Podman history", func() {
|
|||||||
session := podmanTest.Podman([]string{"history", "--format=json", ALPINE})
|
session := podmanTest.Podman([]string{"history", "--format=json", ALPINE})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -73,6 +73,6 @@ var _ = Describe("Podman image sign", func() {
|
|||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
fInfos, err := ioutil.ReadDir(filepath.Join(sigDir, "library"))
|
fInfos, err := ioutil.ReadDir(filepath.Join(sigDir, "library"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(len(fInfos) > 1).To(BeTrue())
|
Expect(len(fInfos)).To(BeNumerically(">", 1), "len(fInfos)")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -94,14 +94,14 @@ var _ = Describe("Podman images", func() {
|
|||||||
session := podmanTest.Podman([]string{"images", "--format=json", "not-existing-image"})
|
session := podmanTest.Podman([]string{"images", "--format=json", "not-existing-image"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman images in JSON format", func() {
|
It("podman images in JSON format", func() {
|
||||||
session := podmanTest.Podman([]string{"images", "--format=json"})
|
session := podmanTest.Podman([]string{"images", "--format=json"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman images in GO template format", func() {
|
It("podman images in GO template format", func() {
|
||||||
@ -254,7 +254,7 @@ WORKDIR /test
|
|||||||
session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE})
|
session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
imageData := session.InspectImageJSON()
|
imageData := session.InspectImageJSON()
|
||||||
|
|
||||||
result := podmanTest.Podman([]string{"images", "sha256:" + imageData[0].ID})
|
result := podmanTest.Podman([]string{"images", "sha256:" + imageData[0].ID})
|
||||||
@ -266,7 +266,7 @@ WORKDIR /test
|
|||||||
session := podmanTest.Podman([]string{"image", "inspect", "--format=json", ALPINE})
|
session := podmanTest.Podman([]string{"image", "inspect", "--format=json", ALPINE})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
imageData := session.InspectImageJSON()
|
imageData := session.InspectImageJSON()
|
||||||
|
|
||||||
result := podmanTest.Podman([]string{"image", "ls", fmt.Sprintf("sha256:%s", imageData[0].ID)})
|
result := podmanTest.Podman([]string{"image", "ls", fmt.Sprintf("sha256:%s", imageData[0].ID)})
|
||||||
|
@ -38,7 +38,7 @@ var _ = Describe("Podman inspect", func() {
|
|||||||
session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE})
|
session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
imageData := session.InspectImageJSON()
|
imageData := session.InspectImageJSON()
|
||||||
Expect(imageData[0].RepoTags[0]).To(Equal("quay.io/libpod/alpine:latest"))
|
Expect(imageData[0].RepoTags[0]).To(Equal("quay.io/libpod/alpine:latest"))
|
||||||
})
|
})
|
||||||
@ -314,7 +314,7 @@ var _ = Describe("Podman inspect", func() {
|
|||||||
inspect := podmanTest.Podman([]string{"inspect", podName})
|
inspect := podmanTest.Podman([]string{"inspect", podName})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.IsJSONOutputValid()).To(BeTrue())
|
Expect(inspect.OutputToString()).To(BeValidJSON())
|
||||||
podData := inspect.InspectPodArrToJSON()
|
podData := inspect.InspectPodArrToJSON()
|
||||||
Expect(podData[0].Name).To(Equal(podName))
|
Expect(podData[0].Name).To(Equal(podName))
|
||||||
})
|
})
|
||||||
@ -328,7 +328,7 @@ var _ = Describe("Podman inspect", func() {
|
|||||||
inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", podName})
|
inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", podName})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.IsJSONOutputValid()).To(BeTrue())
|
Expect(inspect.OutputToString()).To(BeValidJSON())
|
||||||
podData := inspect.InspectPodArrToJSON()
|
podData := inspect.InspectPodArrToJSON()
|
||||||
Expect(podData[0].Name).To(Equal(podName))
|
Expect(podData[0].Name).To(Equal(podName))
|
||||||
})
|
})
|
||||||
@ -343,7 +343,7 @@ var _ = Describe("Podman inspect", func() {
|
|||||||
inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", "--latest"})
|
inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", "--latest"})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.IsJSONOutputValid()).To(BeTrue())
|
Expect(inspect.OutputToString()).To(BeValidJSON())
|
||||||
podData := inspect.InspectPodArrToJSON()
|
podData := inspect.InspectPodArrToJSON()
|
||||||
Expect(podData[0].Name).To(Equal(podName))
|
Expect(podData[0].Name).To(Equal(podName))
|
||||||
})
|
})
|
||||||
@ -357,14 +357,14 @@ var _ = Describe("Podman inspect", func() {
|
|||||||
inspect1 := podmanTest.Podman([]string{"inspect", "--type", "pod", podName})
|
inspect1 := podmanTest.Podman([]string{"inspect", "--type", "pod", podName})
|
||||||
inspect1.WaitWithDefaultTimeout()
|
inspect1.WaitWithDefaultTimeout()
|
||||||
Expect(inspect1).Should(Exit(0))
|
Expect(inspect1).Should(Exit(0))
|
||||||
Expect(inspect1.IsJSONOutputValid()).To(BeTrue())
|
Expect(inspect1.OutputToString()).To(BeValidJSON())
|
||||||
podData := inspect1.InspectPodArrToJSON()
|
podData := inspect1.InspectPodArrToJSON()
|
||||||
infra := podData[0].Containers[0].Name
|
infra := podData[0].Containers[0].Name
|
||||||
|
|
||||||
inspect := podmanTest.Podman([]string{"inspect", "--latest"})
|
inspect := podmanTest.Podman([]string{"inspect", "--latest"})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.IsJSONOutputValid()).To(BeTrue())
|
Expect(inspect.OutputToString()).To(BeValidJSON())
|
||||||
containerData := inspect.InspectContainerToJSON()
|
containerData := inspect.InspectContainerToJSON()
|
||||||
Expect(containerData[0].Name).To(Equal(infra))
|
Expect(containerData[0].Name).To(Equal(infra))
|
||||||
})
|
})
|
||||||
@ -388,7 +388,7 @@ var _ = Describe("Podman inspect", func() {
|
|||||||
session = podmanTest.Podman([]string{"inspect", volName})
|
session = podmanTest.Podman([]string{"inspect", volName})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman inspect a volume with --format", func() {
|
It("podman inspect a volume with --format", func() {
|
||||||
|
@ -78,7 +78,7 @@ var _ = Describe("Podman mount", func() {
|
|||||||
j := podmanTest.Podman([]string{"mount", "--format=json"})
|
j := podmanTest.Podman([]string{"mount", "--format=json"})
|
||||||
j.WaitWithDefaultTimeout()
|
j.WaitWithDefaultTimeout()
|
||||||
Expect(j).Should(Exit(0))
|
Expect(j).Should(Exit(0))
|
||||||
Expect(j.IsJSONOutputValid()).To(BeTrue())
|
Expect(j.OutputToString()).To(BeValidJSON())
|
||||||
|
|
||||||
j = podmanTest.Podman([]string{"mount", "--format='{{.foobar}}'"})
|
j = podmanTest.Podman([]string{"mount", "--format='{{.foobar}}'"})
|
||||||
j.WaitWithDefaultTimeout()
|
j.WaitWithDefaultTimeout()
|
||||||
@ -332,7 +332,7 @@ var _ = Describe("Podman mount", func() {
|
|||||||
j := podmanTest.Podman([]string{"image", "mount", "--format=json"})
|
j := podmanTest.Podman([]string{"image", "mount", "--format=json"})
|
||||||
j.WaitWithDefaultTimeout()
|
j.WaitWithDefaultTimeout()
|
||||||
Expect(j).Should(Exit(0))
|
Expect(j).Should(Exit(0))
|
||||||
Expect(j.IsJSONOutputValid()).To(BeTrue())
|
Expect(j.OutputToString()).To(BeValidJSON())
|
||||||
|
|
||||||
umount := podmanTest.Podman([]string{"image", "umount", fedoraMinimal})
|
umount := podmanTest.Podman([]string{"image", "umount", fedoraMinimal})
|
||||||
umount.WaitWithDefaultTimeout()
|
umount.WaitWithDefaultTimeout()
|
||||||
|
@ -234,7 +234,7 @@ var _ = Describe("Podman network", func() {
|
|||||||
session := podmanTest.Podman(append([]string{"network", "inspect"}, expectedNetworks...))
|
session := podmanTest.Podman(append([]string{"network", "inspect"}, expectedNetworks...))
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman network inspect", func() {
|
It("podman network inspect", func() {
|
||||||
|
@ -56,7 +56,7 @@ var _ = Describe("Podman pod inspect", func() {
|
|||||||
inspect := podmanTest.Podman([]string{"pod", "inspect", podid})
|
inspect := podmanTest.Podman([]string{"pod", "inspect", podid})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.IsJSONOutputValid()).To(BeTrue())
|
Expect(inspect.OutputToString()).To(BeValidJSON())
|
||||||
podData := inspect.InspectPodToJSON()
|
podData := inspect.InspectPodToJSON()
|
||||||
Expect(podData.ID).To(Equal(podid))
|
Expect(podData.ID).To(Equal(podid))
|
||||||
})
|
})
|
||||||
@ -75,7 +75,7 @@ var _ = Describe("Podman pod inspect", func() {
|
|||||||
inspect := podmanTest.Podman([]string{"pod", "inspect", podName})
|
inspect := podmanTest.Podman([]string{"pod", "inspect", podName})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.IsJSONOutputValid()).To(BeTrue())
|
Expect(inspect.OutputToString()).To(BeValidJSON())
|
||||||
podData := inspect.InspectPodToJSON()
|
podData := inspect.InspectPodToJSON()
|
||||||
// Let's get the last len(createCommand) items in the command.
|
// Let's get the last len(createCommand) items in the command.
|
||||||
inspectCreateCommand := podData.CreateCommand
|
inspectCreateCommand := podData.CreateCommand
|
||||||
|
@ -149,7 +149,7 @@ var _ = Describe("Podman pod stats", func() {
|
|||||||
stats := podmanTest.Podman([]string{"pod", "stats", "--format", "json", "--no-stream", "-a"})
|
stats := podmanTest.Podman([]string{"pod", "stats", "--format", "json", "--no-stream", "-a"})
|
||||||
stats.WaitWithDefaultTimeout()
|
stats.WaitWithDefaultTimeout()
|
||||||
Expect(stats).Should(Exit(0))
|
Expect(stats).Should(Exit(0))
|
||||||
Expect(stats.IsJSONOutputValid()).To(BeTrue())
|
Expect(stats.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
It("podman pod stats with GO template", func() {
|
It("podman pod stats with GO template", func() {
|
||||||
_, ec, podid := podmanTest.CreatePod(nil)
|
_, ec, podid := podmanTest.CreatePod(nil)
|
||||||
@ -189,6 +189,6 @@ var _ = Describe("Podman pod stats", func() {
|
|||||||
stats := podmanTest.Podman([]string{"pod", "stats", "--format", "json", "--no-stream", podName})
|
stats := podmanTest.Podman([]string{"pod", "stats", "--format", "json", "--no-stream", podName})
|
||||||
stats.WaitWithDefaultTimeout()
|
stats.WaitWithDefaultTimeout()
|
||||||
Expect(stats).Should(Exit(0))
|
Expect(stats).Should(Exit(0))
|
||||||
Expect(stats.IsJSONOutputValid()).To(BeTrue())
|
Expect(stats.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -239,7 +239,7 @@ var _ = Describe("Podman ps", func() {
|
|||||||
result := podmanTest.Podman([]string{"ps", "--format", "json"})
|
result := podmanTest.Podman([]string{"ps", "--format", "json"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.IsJSONOutputValid()).To(BeTrue())
|
Expect(result.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman ps namespace flag with json format", func() {
|
It("podman ps namespace flag with json format", func() {
|
||||||
@ -249,7 +249,7 @@ var _ = Describe("Podman ps", func() {
|
|||||||
result := podmanTest.Podman([]string{"ps", "-a", "--ns", "--format", "json"})
|
result := podmanTest.Podman([]string{"ps", "-a", "--ns", "--format", "json"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.IsJSONOutputValid()).To(BeTrue())
|
Expect(result.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman ps json format Created field is int64", func() {
|
It("podman ps json format Created field is int64", func() {
|
||||||
@ -275,7 +275,7 @@ var _ = Describe("Podman ps", func() {
|
|||||||
result := podmanTest.Podman([]string{"ps", "-a", "--format", "json"})
|
result := podmanTest.Podman([]string{"ps", "-a", "--format", "json"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.IsJSONOutputValid()).To(BeTrue())
|
Expect(result.OutputToString()).To(BeValidJSON())
|
||||||
// must contain "Status"
|
// must contain "Status"
|
||||||
match, StatusLine := result.GrepString(`Status`)
|
match, StatusLine := result.GrepString(`Status`)
|
||||||
Expect(match).To(BeTrue())
|
Expect(match).To(BeTrue())
|
||||||
|
@ -134,7 +134,7 @@ registries = ['{{.Host}}:{{.Port}}']`
|
|||||||
search := podmanTest.Podman([]string{"search", "--format", "json", "alpine"})
|
search := podmanTest.Podman([]string{"search", "--format", "json", "alpine"})
|
||||||
search.WaitWithDefaultTimeout()
|
search.WaitWithDefaultTimeout()
|
||||||
Expect(search).Should(Exit(0))
|
Expect(search).Should(Exit(0))
|
||||||
Expect(search.IsJSONOutputValid()).To(BeTrue())
|
Expect(search.OutputToString()).To(BeValidJSON())
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine"))
|
Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine"))
|
||||||
|
|
||||||
// Test for https://github.com/containers/podman/issues/11894
|
// Test for https://github.com/containers/podman/issues/11894
|
||||||
@ -151,7 +151,7 @@ registries = ['{{.Host}}:{{.Port}}']`
|
|||||||
search := podmanTest.Podman([]string{"search", "--list-tags", "--format", "json", "alpine"})
|
search := podmanTest.Podman([]string{"search", "--list-tags", "--format", "json", "alpine"})
|
||||||
search.WaitWithDefaultTimeout()
|
search.WaitWithDefaultTimeout()
|
||||||
Expect(search).Should(Exit(0))
|
Expect(search).Should(Exit(0))
|
||||||
Expect(search.IsJSONOutputValid()).To(BeTrue())
|
Expect(search.OutputToString()).To(BeValidJSON())
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine"))
|
Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine"))
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("3.10"))
|
Expect(search.OutputToString()).To(ContainSubstring("3.10"))
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("2.7"))
|
Expect(search.OutputToString()).To(ContainSubstring("2.7"))
|
||||||
|
@ -78,7 +78,7 @@ var _ = Describe("Podman secret", func() {
|
|||||||
inspect := podmanTest.Podman([]string{"secret", "inspect", secrID})
|
inspect := podmanTest.Podman([]string{"secret", "inspect", secrID})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.IsJSONOutputValid()).To(BeTrue())
|
Expect(inspect.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman secret inspect with --format", func() {
|
It("podman secret inspect with --format", func() {
|
||||||
@ -115,7 +115,7 @@ var _ = Describe("Podman secret", func() {
|
|||||||
inspect := podmanTest.Podman([]string{"secret", "inspect", secrID, secrID2})
|
inspect := podmanTest.Podman([]string{"secret", "inspect", secrID, secrID2})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.IsJSONOutputValid()).To(BeTrue())
|
Expect(inspect.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman secret inspect bogus", func() {
|
It("podman secret inspect bogus", func() {
|
||||||
|
@ -148,7 +148,7 @@ var _ = Describe("Podman stats", func() {
|
|||||||
stats := podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "json"})
|
stats := podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "json"})
|
||||||
stats.WaitWithDefaultTimeout()
|
stats.WaitWithDefaultTimeout()
|
||||||
Expect(stats).Should(Exit(0))
|
Expect(stats).Should(Exit(0))
|
||||||
Expect(stats.IsJSONOutputValid()).To(BeTrue())
|
Expect(stats.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman stats on a container with no net ns", func() {
|
It("podman stats on a container with no net ns", func() {
|
||||||
|
@ -76,7 +76,7 @@ var _ = Describe("Podman trust", func() {
|
|||||||
session := podmanTest.Podman([]string{"image", "trust", "show", "--registrypath", filepath.Join(INTEGRATION_ROOT, "test"), "--policypath", filepath.Join(INTEGRATION_ROOT, "test/policy.json"), "--json"})
|
session := podmanTest.Podman([]string{"image", "trust", "show", "--registrypath", filepath.Join(INTEGRATION_ROOT, "test"), "--policypath", filepath.Join(INTEGRATION_ROOT, "test/policy.json"), "--json"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
var teststruct []map[string]string
|
var teststruct []map[string]string
|
||||||
json.Unmarshal(session.Out.Contents(), &teststruct)
|
json.Unmarshal(session.Out.Contents(), &teststruct)
|
||||||
Expect(len(teststruct)).To(Equal(3))
|
Expect(len(teststruct)).To(Equal(3))
|
||||||
@ -118,7 +118,7 @@ var _ = Describe("Podman trust", func() {
|
|||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
contents, err := ioutil.ReadFile(filepath.Join(INTEGRATION_ROOT, "test/policy.json"))
|
contents, err := ioutil.ReadFile(filepath.Join(INTEGRATION_ROOT, "test/policy.json"))
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
Expect(string(session.Out.Contents())).To(Equal(string(contents) + "\n"))
|
Expect(string(session.Out.Contents())).To(Equal(string(contents) + "\n"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -43,7 +43,7 @@ var _ = Describe("Podman volume inspect", func() {
|
|||||||
session = podmanTest.Podman([]string{"volume", "inspect", volName})
|
session = podmanTest.Podman([]string{"volume", "inspect", volName})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman inspect volume with Go format", func() {
|
It("podman inspect volume with Go format", func() {
|
||||||
|
@ -64,7 +64,7 @@ var _ = Describe("Podman volume ls", func() {
|
|||||||
session = podmanTest.Podman([]string{"volume", "ls", "--format", "json"})
|
session = podmanTest.Podman([]string{"volume", "ls", "--format", "json"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
Expect(session.OutputToString()).To(BeValidJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman ls volume with Go template", func() {
|
It("podman ls volume with Go template", func() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
@ -166,3 +167,32 @@ func (matcher *ExitMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type validJSONMatcher struct {
|
||||||
|
types.GomegaMatcher
|
||||||
|
}
|
||||||
|
|
||||||
|
func BeValidJSON() *validJSONMatcher {
|
||||||
|
return &validJSONMatcher{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (matcher *validJSONMatcher) Match(actual interface{}) (success bool, err error) {
|
||||||
|
s, ok := actual.(string)
|
||||||
|
if !ok {
|
||||||
|
return false, fmt.Errorf("validJSONMatcher expects a string, not %q", actual)
|
||||||
|
}
|
||||||
|
|
||||||
|
var i interface{}
|
||||||
|
if err := json.Unmarshal([]byte(s), &i); err != nil {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (matcher *validJSONMatcher) FailureMessage(actual interface{}) (message string) {
|
||||||
|
return format.Message(actual, "to be valid JSON")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (matcher *validJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||||
|
return format.Message(actual, "to _not_ be valid JSON")
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user