mirror of https://github.com/docker/cli.git
e2e: remove deprecated io/ioutil and use t.TempDir()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
39ace68061
commit
e89af84ffc
|
@ -1,7 +1,6 @@
|
|||
package context
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
|
@ -21,10 +20,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,
|
||||
|
@ -38,10 +34,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,
|
||||
|
@ -55,7 +48,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
|
||||
|
|
|
@ -2,7 +2,7 @@ package image
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -141,7 +141,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)
|
||||
|
|
Loading…
Reference in New Issue