diff options
author | Ed Santiago <santiago@redhat.com> | 2022-07-08 06:19:30 -0600 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2022-07-08 06:19:30 -0600 |
commit | 1e7686df6e3e1743273040b4e0652c6272717b15 (patch) | |
tree | 14c1e99ba2cd38ce6957c5fad19aaa381d93bab6 /test | |
parent | 6087fb2116aaeae995e8423872ffe637e8be128f (diff) | |
download | podman-1e7686df6e3e1743273040b4e0652c6272717b15.tar.gz podman-1e7686df6e3e1743273040b4e0652c6272717b15.tar.bz2 podman-1e7686df6e3e1743273040b4e0652c6272717b15.zip |
Manifest test cleanup: use defer()
Followup to #14845: use defer(), not fragile global context,
to stop registry and clean up temporary envariable. Thanks
to mitr for the suggestion.
Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/manifest_test.go | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go index 280276973..1f58419a1 100644 --- a/test/e2e/manifest_test.go +++ b/test/e2e/manifest_test.go @@ -17,7 +17,6 @@ var _ = Describe("Podman manifest", func() { tempdir string err error podmanTest *PodmanTestIntegration - registry *podmanRegistry.Registry ) const ( @@ -40,13 +39,6 @@ var _ = Describe("Podman manifest", 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() f := CurrentGinkgoTestDescription() processTestResult(f) @@ -312,8 +304,13 @@ var _ = Describe("Podman manifest", func() { opts = strings.Join(getRemoteOptions(podmanTest, nil), " ") } os.Setenv("PODMAN", podmanTest.PodmanBinary+" "+opts) - registry, err = podmanRegistry.StartWithOptions(registryOptions) + registry, err := podmanRegistry.StartWithOptions(registryOptions) Expect(err).To(BeNil()) + defer func() { + err := registry.Stop() + Expect(err).To(BeNil()) + os.Unsetenv("PODMAN") + }() session := podmanTest.Podman([]string{"manifest", "create", "foo"}) 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.WaitWithDefaultTimeout() Expect(push).To(ExitWithError()) - - err = registry.Stop() - Expect(err).To(BeNil()) - registry = nil }) It("push with error", func() { |