diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-11-04 06:18:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 06:18:08 -0500 |
commit | 7699557b5d644c31b139b24eb2a260a6ec624b19 (patch) | |
tree | bc1e7f645dbf2806b3c555b4e23bddd91ae4c35b /test | |
parent | dfecb48f61fb0ee32f65ce66f5a32f2d41232e41 (diff) | |
parent | 2b859a9d183861ec2e85dee28c9843401f1830aa (diff) | |
download | podman-7699557b5d644c31b139b24eb2a260a6ec624b19.tar.gz podman-7699557b5d644c31b139b24eb2a260a6ec624b19.tar.bz2 podman-7699557b5d644c31b139b24eb2a260a6ec624b19.zip |
Merge pull request #8225 from debarshiray/wip/rishi/exec_test-use-containsubstring
Improve error messages from failing tests
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/exec_test.go | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index a698cd4b3..f61f52589 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -87,14 +87,12 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--env", "FOO=BAR", "test1", "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString("BAR") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("BAR")) session = podmanTest.Podman([]string{"exec", "--env", "PATH=/bin", "test1", "printenv", "PATH"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ = session.GrepString("/bin") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("/bin")) }) It("podman exec os.Setenv env", func() { @@ -107,8 +105,7 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--env", "FOO", "test1", "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString("BAR") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("BAR")) os.Unsetenv("FOO") }) @@ -142,8 +139,7 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--interactive", "--tty", "test1", "/usr/bin/stty", "--all"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString(" onlcr") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(" onlcr")) }) It("podman exec simple command with user", func() { @@ -199,14 +195,12 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--workdir", "/tmp", "test1", "pwd"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString("/tmp") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("/tmp")) session = podmanTest.Podman([]string{"exec", "-w", "/tmp", "test1", "pwd"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ = session.GrepString("/tmp") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("/tmp")) }) It("podman exec missing working directory test", func() { @@ -280,7 +274,7 @@ var _ = Describe("Podman exec", func() { exec := podmanTest.Podman([]string{"exec", "-ti", ctrName2, "id"}) exec.WaitWithDefaultTimeout() Expect(exec.ExitCode()).To(Equal(0)) - Expect(strings.Contains(exec.OutputToString(), fmt.Sprintf("%s(%s)", gid, groupName))).To(BeTrue()) + Expect(exec.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s(%s)", gid, groupName))) }) It("podman exec preserves container groups with --user and --group-add", func() { @@ -300,9 +294,9 @@ RUN useradd -u 1000 auser` exec.WaitWithDefaultTimeout() Expect(exec.ExitCode()).To(Equal(0)) output := exec.OutputToString() - Expect(strings.Contains(output, "4000(first)")).To(BeTrue()) - Expect(strings.Contains(output, "4001(second)")).To(BeTrue()) - Expect(strings.Contains(output, "1000(auser)")).To(BeTrue()) + Expect(output).To(ContainSubstring("4000(first)")) + Expect(output).To(ContainSubstring("4001(second)")) + Expect(output).To(ContainSubstring("1000(auser)")) // Kill the container just so the test does not take 15 seconds to stop. kill := podmanTest.Podman([]string{"kill", ctrName}) @@ -323,7 +317,7 @@ RUN useradd -u 1000 auser` data := podmanTest.InspectContainer(ctrName) Expect(len(data)).To(Equal(1)) Expect(len(data[0].ExecIDs)).To(Equal(1)) - Expect(strings.Contains(exec1.OutputToString(), data[0].ExecIDs[0])).To(BeTrue()) + Expect(exec1.OutputToString()).To(ContainSubstring(data[0].ExecIDs[0])) exec2 := podmanTest.Podman([]string{"exec", "-t", "-i", ctrName, "ps", "-a"}) exec2.WaitWithDefaultTimeout() |