mirror of
https://github.com/containers/skopeo.git
synced 2025-05-04 22:16:43 +00:00
Use testing.T.Setenv instead of os.Setenv in tests
... to benefit from Go 1.17. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
a3a72342f2
commit
92c0d0c09d
cmd/skopeo
@ -38,8 +38,7 @@ func TestStandaloneSign(t *testing.T) {
|
|||||||
|
|
||||||
manifestPath := "fixtures/image.manifest.json"
|
manifestPath := "fixtures/image.manifest.json"
|
||||||
dockerReference := "testing/manifest"
|
dockerReference := "testing/manifest"
|
||||||
os.Setenv("GNUPGHOME", "fixtures")
|
t.Setenv("GNUPGHOME", "fixtures")
|
||||||
defer os.Unsetenv("GNUPGHOME")
|
|
||||||
|
|
||||||
// Invalid command-line arguments
|
// Invalid command-line arguments
|
||||||
for _, args := range [][]string{
|
for _, args := range [][]string{
|
||||||
@ -101,8 +100,7 @@ func TestStandaloneVerify(t *testing.T) {
|
|||||||
manifestPath := "fixtures/image.manifest.json"
|
manifestPath := "fixtures/image.manifest.json"
|
||||||
signaturePath := "fixtures/image.signature"
|
signaturePath := "fixtures/image.signature"
|
||||||
dockerReference := "testing/manifest"
|
dockerReference := "testing/manifest"
|
||||||
os.Setenv("GNUPGHOME", "fixtures")
|
t.Setenv("GNUPGHOME", "fixtures")
|
||||||
defer os.Unsetenv("GNUPGHOME")
|
|
||||||
|
|
||||||
// Invalid command-line arguments
|
// Invalid command-line arguments
|
||||||
for _, args := range [][]string{
|
for _, args := range [][]string{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/containers/image/v5/manifest"
|
"github.com/containers/image/v5/manifest"
|
||||||
@ -128,17 +127,9 @@ func TestImageDestOptionsNewSystemContext(t *testing.T) {
|
|||||||
DockerRegistryUserAgent: defaultUserAgent,
|
DockerRegistryUserAgent: defaultUserAgent,
|
||||||
}, res)
|
}, 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"
|
authFile := "/tmp/auth.json"
|
||||||
// Make sure when REGISTRY_AUTH_FILE is set the auth file is used
|
// 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”
|
// Explicitly set everything to default, except for when the default is “not present”
|
||||||
opts = fakeImageDestOptions(t, "dest-", true, []string{}, []string{
|
opts = fakeImageDestOptions(t, "dest-", true, []string{}, []string{
|
||||||
|
Loading…
Reference in New Issue
Block a user