mirror of
https://github.com/containers/podman.git
synced 2025-06-19 16:33:24 +08:00
Merge pull request #14872 from edsantiago/deferred_defer
Manifest test cleanup: use defer()
This commit is contained in:
@ -17,7 +17,6 @@ var _ = Describe("Podman manifest", func() {
|
|||||||
tempdir string
|
tempdir string
|
||||||
err error
|
err error
|
||||||
podmanTest *PodmanTestIntegration
|
podmanTest *PodmanTestIntegration
|
||||||
registry *podmanRegistry.Registry
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -40,13 +39,6 @@ var _ = Describe("Podman manifest", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
// if auth test fails, it will leave a registry running
|
|
||||||
if registry != nil {
|
|
||||||
_ = registry.Stop()
|
|
||||||
}
|
|
||||||
// Also from auth test; don't propagate it to other tests
|
|
||||||
os.Unsetenv("PODMAN")
|
|
||||||
|
|
||||||
podmanTest.Cleanup()
|
podmanTest.Cleanup()
|
||||||
f := CurrentGinkgoTestDescription()
|
f := CurrentGinkgoTestDescription()
|
||||||
processTestResult(f)
|
processTestResult(f)
|
||||||
@ -312,8 +304,13 @@ var _ = Describe("Podman manifest", func() {
|
|||||||
opts = strings.Join(getRemoteOptions(podmanTest, nil), " ")
|
opts = strings.Join(getRemoteOptions(podmanTest, nil), " ")
|
||||||
}
|
}
|
||||||
os.Setenv("PODMAN", podmanTest.PodmanBinary+" "+opts)
|
os.Setenv("PODMAN", podmanTest.PodmanBinary+" "+opts)
|
||||||
registry, err = podmanRegistry.StartWithOptions(registryOptions)
|
registry, err := podmanRegistry.StartWithOptions(registryOptions)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
defer func() {
|
||||||
|
err := registry.Stop()
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
os.Unsetenv("PODMAN")
|
||||||
|
}()
|
||||||
|
|
||||||
session := podmanTest.Podman([]string{"manifest", "create", "foo"})
|
session := podmanTest.Podman([]string{"manifest", "create", "foo"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
@ -342,10 +339,6 @@ var _ = Describe("Podman manifest", func() {
|
|||||||
push = podmanTest.Podman([]string{"manifest", "push", "--tls-verify=false", "--creds=podmantest:wrongpasswd", "foo", "localhost:" + registry.Port + "/credstest"})
|
push = podmanTest.Podman([]string{"manifest", "push", "--tls-verify=false", "--creds=podmantest:wrongpasswd", "foo", "localhost:" + registry.Port + "/credstest"})
|
||||||
push.WaitWithDefaultTimeout()
|
push.WaitWithDefaultTimeout()
|
||||||
Expect(push).To(ExitWithError())
|
Expect(push).To(ExitWithError())
|
||||||
|
|
||||||
err = registry.Stop()
|
|
||||||
Expect(err).To(BeNil())
|
|
||||||
registry = nil
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("push with error", func() {
|
It("push with error", func() {
|
||||||
|
Reference in New Issue
Block a user