e2e: remove deprecated io/ioutil and use t.TempDir()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit e89af84ffc)
Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Sebastiaan van Stijn 2022-02-25 15:32:16 +01:00 committed by Cory Snider
parent 58d486bac7
commit ac72d64c30
2 changed files with 5 additions and 12 deletions

View File

@ -1,7 +1,6 @@
package context
import (
"io/ioutil"
"os"
"testing"
@ -24,10 +23,7 @@ func TestContextList(t *testing.T) {
}
func TestContextImportNoTLS(t *testing.T) {
d, _ := ioutil.TempDir("", "")
defer func() {
os.RemoveAll(d)
}()
d := t.TempDir()
cmd := icmd.Command("docker", "context", "import", "remote", "./testdata/test-dockerconfig.tar")
cmd.Env = append(cmd.Env,
"DOCKER_CONFIG="+d,
@ -44,10 +40,7 @@ func TestContextImportNoTLS(t *testing.T) {
}
func TestContextImportTLS(t *testing.T) {
d, _ := ioutil.TempDir("", "")
defer func() {
os.RemoveAll(d)
}()
d := t.TempDir()
cmd := icmd.Command("docker", "context", "import", "test", "./testdata/test-dockerconfig-tls.tar")
cmd.Env = append(cmd.Env,
"DOCKER_CONFIG="+d,
@ -61,7 +54,7 @@ func TestContextImportTLS(t *testing.T) {
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
golden.Assert(t, result.Stdout(), "context-ls-tls.golden")
b, err := ioutil.ReadFile(d + "/contexts/tls/9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08/kubernetes/key.pem")
b, err := os.ReadFile(d + "/contexts/tls/9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08/kubernetes/key.pem")
assert.NilError(t, err)
assert.Equal(t, string(b), `-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEArQk77K5sgrQYY6HiQ1y7AC+67HrRB36oEvR+Fq60RsFcc3cZ

View File

@ -2,7 +2,7 @@ package image
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
@ -129,7 +129,7 @@ func TestBuildIidFileSquash(t *testing.T) {
withWorkingDir(buildDir),
)
result.Assert(t, icmd.Success)
id, err := ioutil.ReadFile(iidfile)
id, err := os.ReadFile(iidfile)
assert.NilError(t, err)
result = icmd.RunCommand("docker", "image", "inspect", "-f", "{{.Id}}", imageTag)
result.Assert(t, icmd.Success)