Merge pull request #111567 from inosato/remove-ioutil-from-component-base

Remove ioutil from component-base
This commit is contained in:
Kubernetes Prow Robot 2022-09-15 17:53:16 -07:00 committed by GitHub
commit ad1e330977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 12 deletions

View File

@ -19,7 +19,6 @@ package testing
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -47,7 +46,7 @@ func RunTestsOnYAMLData(t *testing.T, tests []TestCase) {
}
func decodeYAML(t *testing.T, path string, codec runtime.Codec) runtime.Object {
content, err := ioutil.ReadFile(path)
content, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
@ -72,7 +71,7 @@ func getCodecForGV(codecs serializer.CodecFactory, gv schema.GroupVersion) (runt
}
func matchOutputFile(t *testing.T, actual []byte, expectedFilePath string) {
expected, err := ioutil.ReadFile(expectedFilePath)
expected, err := os.ReadFile(expectedFilePath)
if err != nil && !os.IsNotExist(err) {
t.Fatalf("couldn't read test data: %v", err)
}
@ -97,7 +96,7 @@ func matchOutputFile(t *testing.T, actual []byte, expectedFilePath string) {
if err := os.MkdirAll(filepath.Dir(expectedFilePath), 0755); err != nil {
t.Fatal(err)
}
if err := ioutil.WriteFile(expectedFilePath, actual, 0644); err != nil {
if err := os.WriteFile(expectedFilePath, actual, 0644); err != nil {
t.Fatal(err)
}
t.Error("wrote expected test data... verify, commit, and rerun tests")

View File

@ -18,7 +18,7 @@ package testing
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -47,7 +47,7 @@ func GetRoundtripTestCases(t *testing.T, scheme *runtime.Scheme, codecs serializ
for gk, versions := range versionsForKind {
testdir := filepath.Join("testdata", gk.Kind, "roundtrip")
dirs, err := ioutil.ReadDir(testdir)
dirs, err := os.ReadDir(testdir)
if err != nil {
t.Fatalf("failed to read testdir %s: %v", testdir, err)
}

View File

@ -17,7 +17,7 @@ limitations under the License.
package configz
import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
@ -39,7 +39,7 @@ func TestConfigz(t *testing.T) {
t.Fatalf("err: %v", err)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -53,7 +53,7 @@ func TestConfigz(t *testing.T) {
t.Fatalf("err: %v", err)
}
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -67,7 +67,7 @@ func TestConfigz(t *testing.T) {
t.Fatalf("err: %v", err)
}
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("err: %v", err)
}

View File

@ -17,7 +17,7 @@ limitations under the License.
package metrics
import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
@ -57,7 +57,7 @@ func TestResetHandler(t *testing.T) {
}
rec := httptest.NewRecorder()
resetHandler.ServeHTTP(rec, req)
body, err := ioutil.ReadAll(rec.Result().Body)
body, err := io.ReadAll(rec.Result().Body)
if err != nil {
t.Fatalf("Error reading response body")
}