Skip to content

Commit f53cc4e

Browse files
author
Lucas Yoon
committed
package errors
1 parent 0f75997 commit f53cc4e

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

pkg/utils/overriding/merging_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package overriding
1818

1919
import (
20-
"io/ioutil"
2120
"os"
2221
"path/filepath"
2322
"testing"
@@ -49,7 +48,7 @@ func TestMerging(t *testing.T) {
4948
t.Error(err)
5049
return nil
5150
}
52-
main, err := ioutil.ReadFile(path)
51+
main, err := os.ReadFile(path)
5352
if err != nil {
5453
t.Error(err)
5554
return nil
@@ -58,7 +57,7 @@ func TestMerging(t *testing.T) {
5857
parent := []byte{}
5958
parentFile := filepath.Join(dirPath, "parent.yaml")
6059
if _, err = os.Stat(parentFile); err == nil {
61-
parent, err = ioutil.ReadFile(parentFile)
60+
parent, err = os.ReadFile(parentFile)
6261
if err != nil {
6362
t.Error(err)
6463
return nil
@@ -68,7 +67,7 @@ func TestMerging(t *testing.T) {
6867
plugins := [][]byte{}
6968
pluginFile := filepath.Join(dirPath, "plugin.yaml")
7069
if _, err = os.Stat(pluginFile); err == nil {
71-
plugin, err := ioutil.ReadFile(filepath.Join(dirPath, "plugin.yaml"))
70+
plugin, err := os.ReadFile(filepath.Join(dirPath, "plugin.yaml"))
7271
if err != nil {
7372
t.Error(err)
7473
return nil
@@ -79,7 +78,7 @@ func TestMerging(t *testing.T) {
7978
resultError := ""
8079
errorFile := filepath.Join(dirPath, "result-error.txt")
8180
if _, err = os.Stat(errorFile); err == nil {
82-
resultErrorBytes, err := ioutil.ReadFile(errorFile)
81+
resultErrorBytes, err := os.ReadFile(errorFile)
8382
if err != nil {
8483
t.Error(err)
8584
return nil

pkg/utils/overriding/overriding_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package overriding
1818

1919
import (
20-
"io/ioutil"
2120
"os"
2221
"path/filepath"
2322
"strings"
@@ -200,13 +199,13 @@ func TestOverridingPatches(t *testing.T) {
200199
t.Error(err)
201200
return nil
202201
}
203-
original, err := ioutil.ReadFile(path)
202+
original, err := os.ReadFile(path)
204203
if err != nil {
205204
t.Error(err)
206205
return nil
207206
}
208207
dirPath := filepath.Dir(path)
209-
patch, err := ioutil.ReadFile(filepath.Join(dirPath, "patch.yaml"))
208+
patch, err := os.ReadFile(filepath.Join(dirPath, "patch.yaml"))
210209
if err != nil {
211210
t.Error(err)
212211
return nil
@@ -215,7 +214,7 @@ func TestOverridingPatches(t *testing.T) {
215214
resultError := ""
216215
errorFile := filepath.Join(dirPath, "result-error.txt")
217216
if _, err = os.Stat(errorFile); err == nil {
218-
resultErrorBytes, err := ioutil.ReadFile(errorFile)
217+
resultErrorBytes, err := os.ReadFile(errorFile)
219218
if err != nil {
220219
t.Error(err)
221220
return nil
@@ -252,7 +251,7 @@ func TestPluginOverrides(t *testing.T) {
252251
}
253252

254253
func readFileToStruct(t *testing.T, path string, into interface{}) {
255-
bytes, err := ioutil.ReadFile(path)
254+
bytes, err := os.ReadFile(path)
256255
if err != nil {
257256
t.Fatalf("Failed to read test file from %s: %s", path, err.Error())
258257
}

pkg/validation/variables/variables_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package variables
1818

1919
import (
20-
"io/ioutil"
2120
"reflect"
2221
"testing"
2322

@@ -174,7 +173,7 @@ func TestValidateAndReplaceDataWithVariable(t *testing.T) {
174173
}
175174

176175
func readFileToStruct(t *testing.T, path string, into interface{}) {
177-
bytes, err := ioutil.ReadFile(path)
176+
bytes, err := os.ReadFile(path)
178177
if err != nil {
179178
t.Fatalf("Failed to read test file from %s: %s", path, err.Error())
180179
}

test/v200/schemaTest/schema_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"encoding/json"
2222
"github.com/ghodss/yaml"
2323
"github.com/santhosh-tekuri/jsonschema"
24-
"io/ioutil"
24+
"io"
2525
"os"
2626
"path/filepath"
2727
"strings"
@@ -62,7 +62,7 @@ func Test_Schema(t *testing.T) {
6262
os.Mkdir(tempDir, 0755)
6363

6464
// Read the content of the jso directory to find test files
65-
files, err := ioutil.ReadDir(jsonDir)
65+
files, err := os.ReadDir(jsonDir)
6666
if err != nil {
6767
t.Fatalf("Error finding test json files in : %s : %v", jsonDir, err)
6868
}
@@ -82,7 +82,7 @@ func Test_Schema(t *testing.T) {
8282
}
8383

8484
// Read contents of the json file which defines the tests to run
85-
byteValue, err := ioutil.ReadAll(testJson)
85+
byteValue, err := io.ReadAll(testJson)
8686
if err != nil {
8787
t.Errorf("FAIL : failed to read : %s : %v", testJsonFile.Name(), err)
8888
}
@@ -127,7 +127,7 @@ func Test_Schema(t *testing.T) {
127127
}
128128

129129
// Read contents of the json file which defines the tests to run
130-
byteValue, err := ioutil.ReadAll(testsToRunJson)
130+
byteValue, err := io.ReadAll(testsToRunJson)
131131
if err != nil {
132132
t.Fatalf("FAIL : failed to read : %s : %v", testJsonContent.Tests[m], err)
133133
}
@@ -165,7 +165,7 @@ func Test_Schema(t *testing.T) {
165165
// Now add each of the yaml sippets used the make the yaml file for test
166166
for j := 0; j < len(testsToRunContent.Tests[i].Files); j++ {
167167
// Read the snippet
168-
data, err := ioutil.ReadFile(filepath.Join(testDir, testsToRunContent.Tests[i].Files[j]))
168+
data, err := os.ReadFile(filepath.Join(testDir, testsToRunContent.Tests[i].Files[j]))
169169
if err != nil {
170170
t.Errorf("FAIL: failed reading %s: %v", filepath.Join(testDir, testsToRunContent.Tests[i].Files[j]), err)
171171
testYamlComplete = false
@@ -186,7 +186,7 @@ func Test_Schema(t *testing.T) {
186186
}
187187

188188
// Read the created yaml file, ready for converison to json
189-
data, err := ioutil.ReadFile(filepath.Join(testTempDir, testsToRunContent.Tests[i].FileName))
189+
data, err := os.ReadFile(filepath.Join(testTempDir, testsToRunContent.Tests[i].FileName))
190190
if err != nil {
191191
t.Errorf(" FAIL: unable to read %s: %v", testsToRunContent.Tests[i].FileName, err)
192192
f.Close()

test/v200/utils/api/test_utils.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import (
2020
"bytes"
2121
"errors"
2222
"fmt"
23-
"io/ioutil"
23+
"io"
24+
"os"
2425
"strconv"
2526
"strings"
2627
"testing"
@@ -66,7 +67,7 @@ func (devfileValidator DevfileValidator) WriteAndValidate(devfile *commonUtils.T
6667
func (schemaFile *SchemaFile) checkWithSchema(devfile string, expectedMessage string) error {
6768

6869
// Read the created yaml file, ready for converison to json
69-
devfileData, err := ioutil.ReadFile(devfile)
70+
devfileData, err := os.ReadFile(devfile)
7071
if err != nil {
7172
commonUtils.LogErrorMessage(fmt.Sprintf(" FAIL: schema : unable to read %s: %v", devfile, err))
7273
return err
@@ -140,7 +141,7 @@ func writeDevfile(devfile *commonUtils.TestDevfile) error {
140141
if marshallErr != nil {
141142
err = errors.New(commonUtils.LogErrorMessage(fmt.Sprintf("Marshall devfile %s : %v", devfile.FileName, marshallErr)))
142143
} else {
143-
err = ioutil.WriteFile(fileName, c, 0644)
144+
err = os.WriteFile(fileName, c, 0644)
144145
if err != nil {
145146
commonUtils.LogErrorMessage(fmt.Sprintf("Write devfile %s : %v", devfile.FileName, err))
146147
}

0 commit comments

Comments
 (0)