Просмотр исходного кода

Use functions from os instead of io/ioutil

Mariano Cano 4 лет назад
Родитель
Сommit
f1aabaa99c
3 измененных файлов с 4 добавлено и 7 удалено
  1. 2 3
      ca/identity/identity_test.go
  2. 1 2
      cas/stepcas/stepcas_test.go
  3. 1 2
      templates/templates_test.go

+ 2 - 3
ca/identity/identity_test.go

@@ -5,7 +5,6 @@ import (
 	"crypto/tls"
 	"crypto/tls"
 	"crypto/x509"
 	"crypto/x509"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
@@ -188,7 +187,7 @@ func Test_fileExists(t *testing.T) {
 }
 }
 
 
 func TestWriteDefaultIdentity(t *testing.T) {
 func TestWriteDefaultIdentity(t *testing.T) {
-	tmpDir, err := ioutil.TempDir(os.TempDir(), "go-tests")
+	tmpDir, err := os.MkdirTemp(os.TempDir(), "go-tests")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -373,7 +372,7 @@ func (r *renewer) Renew(tr http.RoundTripper) (*api.SignResponse, error) {
 }
 }
 
 
 func TestIdentity_Renew(t *testing.T) {
 func TestIdentity_Renew(t *testing.T) {
-	tmpDir, err := ioutil.TempDir(os.TempDir(), "go-tests")
+	tmpDir, err := os.MkdirTemp(os.TempDir(), "go-tests")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 1 - 2
cas/stepcas/stepcas_test.go

@@ -10,7 +10,6 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"encoding/pem"
 	"encoding/pem"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"net/http"
 	"net/http"
 	"net/http/httptest"
 	"net/http/httptest"
 	"net/url"
 	"net/url"
@@ -291,7 +290,7 @@ func TestMain(m *testing.M) {
 	}
 	}
 
 
 	// Create test files.
 	// Create test files.
-	path, err := ioutil.TempDir(os.TempDir(), "stepcas")
+	path, err := os.MkdirTemp(os.TempDir(), "stepcas")
 	if err != nil {
 	if err != nil {
 		panic(err)
 		panic(err)
 	}
 	}

+ 1 - 2
templates/templates_test.go

@@ -6,7 +6,6 @@ import (
 	"crypto/rand"
 	"crypto/rand"
 	"encoding/base64"
 	"encoding/base64"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"reflect"
 	"reflect"
@@ -369,7 +368,7 @@ func TestTemplate_Output(t *testing.T) {
 }
 }
 
 
 func TestOutput_Write(t *testing.T) {
 func TestOutput_Write(t *testing.T) {
-	dir, err := ioutil.TempDir("", "test-output-write")
+	dir, err := os.MkdirTemp("", "test-output-write")
 	assert.FatalError(t, err)
 	assert.FatalError(t, err)
 	defer os.RemoveAll(dir)
 	defer os.RemoveAll(dir)