From 97ab9176f77c4fc9c4413afad4d2dcf5fad824b6 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 22 Nov 2021 10:54:22 -0700 Subject: 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 --- test/e2e/ps_test.go | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'test/e2e/ps_test.go') diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 881d9fcf0..0afd74bcb 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -671,51 +671,51 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(5)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) - Expect(session.LineInOutputContains("test3")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) + Expect(session.OutputToString()).To(ContainSubstring("test2")) + Expect(session.OutputToString()).To(ContainSubstring("test3")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "name=test1", "--filter", "name=test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) + Expect(session.OutputToString()).To(ContainSubstring("test2")) // check container id matches with regex session = podmanTest.Podman([]string{"ps", "--all", "--filter", "id=" + cid1[:40], "--filter", "id=" + cid1 + "$"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) session = podmanTest.Podman([]string{"ps", "--filter", "status=created"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test3")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test3")) session = podmanTest.Podman([]string{"ps", "--filter", "status=created", "--filter", "status=exited"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(4)) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) - Expect(session.LineInOutputContains("test3")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test2")) + Expect(session.OutputToString()).To(ContainSubstring("test3")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "label=foo=1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) + Expect(session.OutputToString()).To(ContainSubstring("test2")) session = podmanTest.Podman([]string{"ps", "--filter", "label=foo=1", "--filter", "status=exited"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test2")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "label=foo=1", "--filter", "label=non=1"}) session.WaitWithDefaultTimeout() @@ -726,46 +726,46 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "exited=1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test2")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "exited=1", "--filter", "exited=0"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test2")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "volume=volume1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "volume=/:/test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "before=test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "since=test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test3")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test3")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) }) It("podman ps filter pod", func() { pod1 := podmanTest.Podman([]string{"pod", "create", "--name", "pod1"}) -- cgit v1.2.3-54-g00ecf