mirror of
https://github.com/containers/podman.git
synced 2025-09-17 23:18:39 +08:00

There is no reason to define the same code every time in each file, just use global nodes. This diff should speak for itself. CleanupSecrets()/Volume() no longer call Cleanup() directly, as the global AfterEach node will always call Cleanup() this is no longer necessary. If one AfterEach() node fails it will still run the others. Also always unset the CONTAINERS_CONF env vars. This prevents people from forgetting to unset it. And fix the special CONTAINERS_CONF logic in the system connection tests, we do not want to preserve CONTAINERS_CONF anyway so just remove this logic. Ginkgo orders the BeforeEach and AfterEach nodes. They will be executed from the outer-most defined to inner-most. This means our global BeforeEach is always first. Only then the inner one (in the Describe() function in each file). For AfterEach it is inverted, from the inner to the outer. Also see https://onsi.github.io/ginkgo/#organizing-specs-with-container-nodes Signed-off-by: Paul Holzinger <pholzing@redhat.com>
74 lines
2.5 KiB
Go
74 lines
2.5 KiB
Go
package integration
|
|
|
|
import (
|
|
. "github.com/containers/podman/v4/test/utils"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
. "github.com/onsi/gomega/gexec"
|
|
)
|
|
|
|
var _ = Describe("Podman mount", func() {
|
|
|
|
BeforeEach(func() {
|
|
SkipIfNotRootless("This function is not enabled for rootful podman")
|
|
SkipIfRemote("Podman mount not supported for remote connections")
|
|
})
|
|
|
|
It("podman mount", func() {
|
|
setup := podmanTest.Podman([]string{"create", ALPINE, "ls"})
|
|
setup.WaitWithDefaultTimeout()
|
|
Expect(setup).Should(Exit(0))
|
|
cid := setup.OutputToString()
|
|
|
|
mount := podmanTest.Podman([]string{"mount", cid})
|
|
mount.WaitWithDefaultTimeout()
|
|
Expect(mount).To(ExitWithError())
|
|
Expect(mount.ErrorToString()).To(ContainSubstring("podman unshare"))
|
|
})
|
|
|
|
It("podman unshare podman mount", func() {
|
|
setup := podmanTest.Podman([]string{"create", ALPINE, "ls"})
|
|
setup.WaitWithDefaultTimeout()
|
|
Expect(setup).Should(Exit(0))
|
|
cid := setup.OutputToString()
|
|
|
|
// command: podman <options> unshare podman <options> mount cid
|
|
args := []string{"unshare", podmanTest.PodmanBinary}
|
|
opts := podmanTest.PodmanMakeOptions([]string{"mount", cid}, false, false)
|
|
args = append(args, opts...)
|
|
|
|
// container root file system location is podmanTest.TempDir/...
|
|
// because "--root podmanTest.TempDir/..."
|
|
session := podmanTest.Podman(args)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
Expect(session.OutputToString()).To(ContainSubstring(podmanTest.TempDir))
|
|
})
|
|
|
|
It("podman image mount", func() {
|
|
podmanTest.AddImageToRWStore(ALPINE)
|
|
mount := podmanTest.Podman([]string{"image", "mount", ALPINE})
|
|
mount.WaitWithDefaultTimeout()
|
|
Expect(mount).To(ExitWithError())
|
|
Expect(mount.ErrorToString()).To(ContainSubstring("podman unshare"))
|
|
})
|
|
|
|
It("podman unshare image podman mount", func() {
|
|
podmanTest.AddImageToRWStore(ALPINE)
|
|
setup := podmanTest.Podman([]string{"pull", ALPINE})
|
|
setup.WaitWithDefaultTimeout()
|
|
Expect(setup).Should(Exit(0))
|
|
|
|
// command: podman <options> unshare podman <options> image mount ALPINE
|
|
args := []string{"unshare", podmanTest.PodmanBinary}
|
|
opts := podmanTest.PodmanMakeOptions([]string{"image", "mount", ALPINE}, false, false)
|
|
args = append(args, opts...)
|
|
|
|
// image location is podmanTest.TempDir/... because "--root podmanTest.TempDir/..."
|
|
session := podmanTest.Podman(args)
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session).Should(Exit(0))
|
|
Expect(session.OutputToString()).To(ContainSubstring(podmanTest.TempDir))
|
|
})
|
|
})
|