diff --git a/cmd/skopeo/signing_test.go b/cmd/skopeo/signing_test.go index 28a9dc6a..cbd23de3 100644 --- a/cmd/skopeo/signing_test.go +++ b/cmd/skopeo/signing_test.go @@ -38,8 +38,7 @@ func TestStandaloneSign(t *testing.T) { manifestPath := "fixtures/image.manifest.json" dockerReference := "testing/manifest" - os.Setenv("GNUPGHOME", "fixtures") - defer os.Unsetenv("GNUPGHOME") + t.Setenv("GNUPGHOME", "fixtures") // Invalid command-line arguments for _, args := range [][]string{ @@ -101,8 +100,7 @@ func TestStandaloneVerify(t *testing.T) { manifestPath := "fixtures/image.manifest.json" signaturePath := "fixtures/image.signature" dockerReference := "testing/manifest" - os.Setenv("GNUPGHOME", "fixtures") - defer os.Unsetenv("GNUPGHOME") + t.Setenv("GNUPGHOME", "fixtures") // Invalid command-line arguments for _, args := range [][]string{ diff --git a/cmd/skopeo/utils_test.go b/cmd/skopeo/utils_test.go index 1487a031..4a3464d6 100644 --- a/cmd/skopeo/utils_test.go +++ b/cmd/skopeo/utils_test.go @@ -1,7 +1,6 @@ package main import ( - "os" "testing" "github.com/containers/image/v5/manifest" @@ -128,17 +127,9 @@ func TestImageDestOptionsNewSystemContext(t *testing.T) { DockerRegistryUserAgent: defaultUserAgent, }, res) - oldXRD, hasXRD := os.LookupEnv("REGISTRY_AUTH_FILE") - defer func() { - if hasXRD { - os.Setenv("REGISTRY_AUTH_FILE", oldXRD) - } else { - os.Unsetenv("REGISTRY_AUTH_FILE") - } - }() authFile := "/tmp/auth.json" // Make sure when REGISTRY_AUTH_FILE is set the auth file is used - os.Setenv("REGISTRY_AUTH_FILE", authFile) + t.Setenv("REGISTRY_AUTH_FILE", authFile) // Explicitly set everything to default, except for when the default is “not present” opts = fakeImageDestOptions(t, "dest-", true, []string{}, []string{