delete io/ioutil package as it is deprecated

Signed-off-by: yanggang <gang.yang@daocloud.io>
This commit is contained in:
yanggang
2023-07-21 15:18:31 +08:00
parent 32262babc4
commit bcc69f33f9
4 changed files with 9 additions and 12 deletions
@@ -19,7 +19,7 @@ package controller
import (
"bytes"
"context"
"io/ioutil"
"io"
"testing"
"time"
@@ -163,7 +163,7 @@ func TestBackupFinalizerReconcile(t *testing.T) {
reconciler, backupper := mockBackupFinalizerReconciler(fakeClient, fakeClock)
pluginManager.On("CleanupClients").Return(nil)
backupStore.On("GetBackupItemOperations", test.backup.Name).Return(test.backupOperations, nil)
backupStore.On("GetBackupContents", mock.Anything).Return(ioutil.NopCloser(bytes.NewReader([]byte("hello world"))), nil)
backupStore.On("GetBackupContents", mock.Anything).Return(io.NopCloser(bytes.NewReader([]byte("hello world"))), nil)
backupStore.On("PutBackupContents", mock.Anything, mock.Anything).Return(nil)
backupStore.On("PutBackupMetadata", mock.Anything, mock.Anything).Return(nil)
pluginManager.On("GetBackupItemActionsV2").Return(nil, nil)
+3 -4
View File
@@ -19,7 +19,6 @@ package provider
import (
"context"
"errors"
"io/ioutil"
"os"
"strings"
"testing"
@@ -211,13 +210,13 @@ func TestResticRunRestore(t *testing.T) {
func TestClose(t *testing.T) {
t.Run("Delete existing credentials file", func(t *testing.T) {
// Create temporary files for the credentials and caCert
credentialsFile, err := ioutil.TempFile("", "credentialsFile")
credentialsFile, err := os.CreateTemp("", "credentialsFile")
if err != nil {
t.Fatalf("failed to create temp file: %v", err)
}
defer os.Remove(credentialsFile.Name())
caCertFile, err := ioutil.TempFile("", "caCertFile")
caCertFile, err := os.CreateTemp("", "caCertFile")
if err != nil {
t.Fatalf("failed to create temp file: %v", err)
}
@@ -240,7 +239,7 @@ func TestClose(t *testing.T) {
t.Run("Delete existing caCert file", func(t *testing.T) {
// Create temporary files for the credentials and caCert
caCertFile, err := ioutil.TempFile("", "caCertFile")
caCertFile, err := os.CreateTemp("", "caCertFile")
if err != nil {
t.Fatalf("failed to create temp file: %v", err)
}