From 366d7ba9cceb29428eb4fd1343994fd71df88ff6 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/run.go b/tests/run.go index a26b77f..3741238 100644 --- a/tests/run.go +++ b/tests/run.go @@ -67,6 +67,13 @@ 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)