mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00

...and an optional error-message string, to be checked against stderr. This is a starting point and baby-steps progress toward #18188. There are 249 ExitWithError() checks in test/e2e. It will take weeks to fix them all. This commit enables new functionality: Expect(ExitWithError(125, "expected substring")) ...while also allowing the current empty-args form. Once all 249 empty-args uses are modernized, the matcher code will be cleaned up. I expect it will take several months of light effort to get all e2e tests transitioned to the new form. I am choosing to do so in pieces, for (relative) ease of review. This PR: 1) makes the initial changes described above; and 2) updates a small subset of e2e _test.go files such that: a) ExitWithError() is given an exit code and error string; and b) Exit(Nonzero) is changed to ExitWithError(Nonzero, "string") (when possible) Signed-off-by: Ed Santiago <santiago@redhat.com>
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package integration
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
. "github.com/containers/podman/v5/test/utils"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Podman export", func() {
|
|
|
|
It("podman export output flag", func() {
|
|
_, ec, cid := podmanTest.RunLsContainer("")
|
|
Expect(ec).To(Equal(0))
|
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "container.tar")
|
|
result := podmanTest.Podman([]string{"export", "-o", outfile, cid})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(ExitCleanly())
|
|
_, err := os.Stat(outfile)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
err = os.Remove(outfile)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
})
|
|
|
|
It("podman container export output flag", func() {
|
|
_, ec, cid := podmanTest.RunLsContainer("")
|
|
Expect(ec).To(Equal(0))
|
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "container.tar")
|
|
result := podmanTest.Podman([]string{"container", "export", "-o", outfile, cid})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).Should(ExitCleanly())
|
|
_, err := os.Stat(outfile)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
err = os.Remove(outfile)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
})
|
|
|
|
It("podman export bad filename", func() {
|
|
_, ec, cid := podmanTest.RunLsContainer("")
|
|
Expect(ec).To(Equal(0))
|
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "container:with:colon.tar")
|
|
result := podmanTest.Podman([]string{"export", "-o", outfile, cid})
|
|
result.WaitWithDefaultTimeout()
|
|
Expect(result).To(ExitWithError(125, "invalid filename (should not contain ':')"))
|
|
})
|
|
})
|