From de1aa44cc95e80156df1e55ba12b0d8bcb102f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Thu, 9 Jan 2025 18:30:53 +0100 Subject: [PATCH] Use PodmanExitCleanly in attach_test.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit just as a demonstration. Signed-off-by: Miloslav Trmač --- test/e2e/attach_test.go | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go index c8570da187..fd6d6e6b1a 100644 --- a/test/e2e/attach_test.go +++ b/test/e2e/attach_test.go @@ -20,9 +20,7 @@ var _ = Describe("Podman attach", func() { }) It("podman attach to non-running container", func() { - session := podmanTest.Podman([]string{"create", "--name", "test1", "-i", CITEST_IMAGE, "ls"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + podmanTest.PodmanExitCleanly("create", "--name", "test1", "-i", CITEST_IMAGE, "ls") results := podmanTest.Podman([]string{"attach", "test1"}) results.WaitWithDefaultTimeout() @@ -30,10 +28,7 @@ var _ = Describe("Podman attach", func() { }) It("podman container attach to non-running container", func() { - session := podmanTest.Podman([]string{"container", "create", "--name", "test1", "-i", CITEST_IMAGE, "ls"}) - - session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + podmanTest.PodmanExitCleanly("container", "create", "--name", "test1", "-i", CITEST_IMAGE, "ls") results := podmanTest.Podman([]string{"container", "attach", "test1"}) results.WaitWithDefaultTimeout() @@ -55,9 +50,7 @@ var _ = Describe("Podman attach", func() { }) It("podman attach to a running container", func() { - session := podmanTest.Podman([]string{"run", "-d", "--name", "test", CITEST_IMAGE, "/bin/sh", "-c", "while true; do echo test; sleep 1; done"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + podmanTest.PodmanExitCleanly("run", "-d", "--name", "test", CITEST_IMAGE, "/bin/sh", "-c", "while true; do echo test; sleep 1; done") results := podmanTest.Podman([]string{"attach", "test"}) time.Sleep(2 * time.Second) @@ -67,13 +60,8 @@ var _ = Describe("Podman attach", func() { }) It("podman attach to the latest container", func() { - session := podmanTest.Podman([]string{"run", "-d", "--name", "test1", CITEST_IMAGE, "/bin/sh", "-c", "while true; do echo test1; sleep 1; done"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) - - session = podmanTest.Podman([]string{"run", "-d", "--name", "test2", CITEST_IMAGE, "/bin/sh", "-c", "while true; do echo test2; sleep 1; done"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + podmanTest.PodmanExitCleanly("run", "-d", "--name", "test1", CITEST_IMAGE, "/bin/sh", "-c", "while true; do echo test1; sleep 1; done") + podmanTest.PodmanExitCleanly("run", "-d", "--name", "test2", CITEST_IMAGE, "/bin/sh", "-c", "while true; do echo test2; sleep 1; done") cid := "-l" if IsRemote() { @@ -87,9 +75,7 @@ var _ = Describe("Podman attach", func() { }) It("podman attach to a container with --sig-proxy set to false", func() { - session := podmanTest.Podman([]string{"run", "-d", "--name", "test", CITEST_IMAGE, "/bin/sh", "-c", "while true; do echo test; sleep 1; done"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + podmanTest.PodmanExitCleanly("run", "-d", "--name", "test", CITEST_IMAGE, "/bin/sh", "-c", "while true; do echo test; sleep 1; done") results := podmanTest.Podman([]string{"attach", "--sig-proxy=false", "test"}) time.Sleep(2 * time.Second)