summaryrefslogtreecommitdiff
path: root/test/e2e/run_test.go
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2021-11-22 10:54:22 -0700
committerEd Santiago <santiago@redhat.com>2021-11-22 14:37:43 -0700
commit97ab9176f77c4fc9c4413afad4d2dcf5fad824b6 (patch)
treefc67f0c7dd3304489f89fd58742d3c46431eb44a /test/e2e/run_test.go
parent1bfbb28b0365790552483b961b4bd48a69dd8070 (diff)
downloadpodman-97ab9176f77c4fc9c4413afad4d2dcf5fad824b6.tar.gz
podman-97ab9176f77c4fc9c4413afad4d2dcf5fad824b6.tar.bz2
podman-97ab9176f77c4fc9c4413afad4d2dcf5fad824b6.zip
e2e tests: clean up antihelpful BeTrue()s
Many ginkgo tests have been written to use this evil form: GrepString("foo") Expect(that to BeTrue()) ...which yields horrible useless messages on failure: false is not true Identify those (automatically, via script) and convert to: Expect(output to ContainSubstring("foo")) ...which yields: "this output" does not contain substring "foo" There are still many BeTrue()s left. This is just a start. This is commit 1 of 2. It includes the script I used, and all changes to *.go are those computed by the script. Commit 2 will apply some manual fixes. Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/e2e/run_test.go')
-rw-r--r--test/e2e/run_test.go28
1 files changed, 11 insertions, 17 deletions
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 2be2154ff..ec64d2166 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -152,8 +152,7 @@ var _ = Describe("Podman run", func() {
session := podmanTest.Podman([]string{"run", ALPINE, "find", "/etc", "-name", "hosts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("/etc/hosts")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("/etc/hosts"))
})
It("podman create pod with name in /etc/hosts", func() {
@@ -162,10 +161,8 @@ var _ = Describe("Podman run", func() {
session := podmanTest.Podman([]string{"run", "-ti", "--rm", "--name", name, "--hostname", hostname, ALPINE, "cat", "/etc/hosts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString(name)
- Expect(match).Should(BeTrue())
- match, _ = session.GrepString(hostname)
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring(name))
+ Expect(session.OutputToString()).To(ContainSubstring(hostname))
})
It("podman run a container based on remote image", func() {
@@ -421,16 +418,14 @@ var _ = Describe("Podman run", func() {
session := podmanTest.Podman([]string{"run", "-it", "--security-opt", strings.Join([]string{"seccomp=", forbidGetCWDSeccompProfile()}, ""), ALPINE, "pwd"})
session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError())
- match, _ := session.GrepString("Operation not permitted")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("Operation not permitted"))
})
It("podman run seccomp test --privileged", func() {
session := podmanTest.Podman([]string{"run", "-it", "--privileged", "--security-opt", strings.Join([]string{"seccomp=", forbidGetCWDSeccompProfile()}, ""), ALPINE, "pwd"})
session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError())
- match, _ := session.GrepString("Operation not permitted")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("Operation not permitted"))
})
It("podman run seccomp test --privileged no profile should be unconfined", func() {
@@ -879,14 +874,14 @@ USER bin`, BB)
session := podmanTest.Podman([]string{"run", "--rm", "--group-add=audio", "--group-add=nogroup", "--group-add=777", ALPINE, "id"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(session.LineInOutputContains("777,65533(nogroup)")).To(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("777,65533(nogroup)"))
})
It("podman run with user (default)", func() {
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "id"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(session.LineInOutputContains("uid=0(root) gid=0(root)")).To(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("uid=0(root) gid=0(root)"))
})
It("podman run with user (integer, not in /etc/passwd)", func() {
@@ -900,14 +895,14 @@ USER bin`, BB)
session := podmanTest.Podman([]string{"run", "--rm", "--user=8", ALPINE, "id"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(session.LineInOutputContains("uid=8(mail) gid=12(mail)")).To(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("uid=8(mail) gid=12(mail)"))
})
It("podman run with user (username)", func() {
session := podmanTest.Podman([]string{"run", "--rm", "--user=mail", ALPINE, "id"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(session.LineInOutputContains("uid=8(mail) gid=12(mail)")).To(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("uid=8(mail) gid=12(mail)"))
})
It("podman run with user:group (username:integer)", func() {
@@ -939,7 +934,7 @@ USER bin`, BB)
ps := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc"})
ps.WaitWithDefaultTimeout()
Expect(ps).Should(Exit(0))
- Expect(ps.LineInOutputContains(session.OutputToString())).To(BeTrue())
+ Expect(ps.OutputToString()).To(ContainSubstring(session.OutputToString()))
})
It("podman run with attach stdout does not print stderr", func() {
@@ -1217,8 +1212,7 @@ USER mail`, BB)
check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"})
check.WaitWithDefaultTimeout()
- match, _ := check.GrepString("foobar")
- Expect(match).To(BeTrue())
+ Expect(check.OutputToString()).To(ContainSubstring("foobar"))
})
It("podman run --pod new with hostname", func() {