From f0d9940f92a02a0e99f854919111925b87999cf2 Mon Sep 17 00:00:00 2001 From: Shubharanshu Mahapatra Date: Tue, 20 Aug 2024 13:37:17 -0700 Subject: [PATCH] feat: Add test to check exit code Signed-off-by: Shubharanshu Mahapatra --- tests/run.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/run.go b/tests/run.go index a26b77f..3e33bd1 100644 --- a/tests/run.go +++ b/tests/run.go @@ -67,6 +67,14 @@ func Run(o *RunOption) { }) }) + ginkgo.It("container should exit with exit code in case of an error", func() { + exitCode := 10 + cmd := fmt.Sprintf("exit %d", exitCode) + session := command.RunWithoutSuccessfulExit(o.BaseOpt, "run", "--rm", "--name", testContainerName, + localImages[defaultImage], "sh", "-c", cmd) + gomega.Expect(session.ExitCode()).To(gomega.Equal(exitCode)) + }) + ginkgo.It("with --rm flag, container should be removed when it exits", func() { command.Run(o.BaseOpt, "run", "--rm", "--name", testContainerName, localImages[defaultImage]) err := containerShouldNotExist(o.BaseOpt, testContainerName)