mirror of
https://github.com/containers/podman.git
synced 2025-06-20 00:51:16 +08:00

Followup to #10932: add a validation check to prevent introduction of new 'Expect(foo.ExitCode()).To(...)' patterns. If such use is absolutely necessary -- there is one such instance in the code already -- require that the assertion include a description. Also: clean up instances that were introduced since the merging of #10932. Also: fix one remaining instance in run_exit_test.go: it had a FIXME comment mentioning a race condition, but unfortunately there was no issue or bug ID, hence no way to know if the race is fixed or not. We will assume it is. Signed-off-by: Ed Santiago <santiago@redhat.com>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package integration
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/containers/podman/v3/libpod/define"
|
|
. "github.com/containers/podman/v3/test/utils"
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
. "github.com/onsi/gomega/gexec"
|
|
)
|
|
|
|
var _ = Describe("Podman run exit", func() {
|
|
var (
|
|
tempdir string
|
|
err error
|
|
podmanTest *PodmanTestIntegration
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
tempdir, err = CreateTempDirInTempDir()
|
|
if err != nil {
|
|
os.Exit(1)
|
|
}
|
|
podmanTest = PodmanTestCreate(tempdir)
|
|
podmanTest.Setup()
|
|
podmanTest.SeedImages()
|
|
})
|
|
|
|
AfterEach(func() {
|
|
podmanTest.Cleanup()
|
|
f := CurrentGinkgoTestDescription()
|
|
processTestResult(f)
|
|
|
|
})
|
|
|
|
It("podman run exit define.ExecErrorCodeGeneric", func() {
|
|
result := podmanTest.Podman([]string{"run", "--foobar", ALPINE, "ls", "$tmp"})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(define.ExecErrorCodeGeneric))
|
|
})
|
|
|
|
It("podman run exit ExecErrorCodeCannotInvoke", func() {
|
|
result := podmanTest.Podman([]string{"run", ALPINE, "/etc"})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(define.ExecErrorCodeCannotInvoke))
|
|
})
|
|
|
|
It("podman run exit ExecErrorCodeNotFound", func() {
|
|
result := podmanTest.Podman([]string{"run", ALPINE, "foobar"})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(define.ExecErrorCodeNotFound))
|
|
})
|
|
|
|
It("podman run exit 0", func() {
|
|
result := podmanTest.Podman([]string{"run", ALPINE, "ls"})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(0))
|
|
})
|
|
|
|
It("podman run exit 50", func() {
|
|
result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 50"})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(Exit(50))
|
|
})
|
|
})
|