Skip to content

Commit 072a43e

Browse files
committed
chore: replace deprecated io/ioutil with os package in test files
1 parent ddd2b73 commit 072a43e

File tree

7 files changed

+15
-22
lines changed

7 files changed

+15
-22
lines changed

cmd/add_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"strings"
98

@@ -54,8 +53,8 @@ var _ = Describe("Add Command", func() {
5453

5554
// copy if copy is true. otherwise it will be fresh empty config file
5655
if copy {
57-
original, _ := ioutil.ReadFile("../testdata/config.yaml")
58-
ioutil.WriteFile(testConfigFile, original, 0644)
56+
original, _ := os.ReadFile("../testdata/config.yaml")
57+
os.WriteFile(testConfigFile, original, 0644)
5958
}
6059

6160
cmd.SetArgs(args) // set the arg for each test case

cmd/delete_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"os"
87

98
. "github.com/onsi/ginkgo/v2"
@@ -56,8 +55,8 @@ var _ = Describe("Edit Command", func() {
5655

5756
// copy if copy is true. otherwise it will be fresh empty config file
5857
if copy {
59-
oiginal, _ := ioutil.ReadFile("../testdata/config.yaml")
60-
ioutil.WriteFile(testConfigFile, oiginal, 0644)
58+
original, _ := os.ReadFile("../testdata/config.yaml")
59+
os.WriteFile(testConfigFile, original, 0644)
6160
}
6261

6362
cmd.SetArgs(args) // set the arg for each test case

cmd/edit_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"strings"
98

@@ -54,8 +53,8 @@ var _ = Describe("Edit Command", func() {
5453

5554
// copy if copy is true. otherwise it will be fresh empty config file
5655
if copy {
57-
oiginal, _ := ioutil.ReadFile("../testdata/config.yaml")
58-
ioutil.WriteFile(testConfigFile, oiginal, 0644)
56+
original, _ := os.ReadFile("../testdata/config.yaml")
57+
os.WriteFile(testConfigFile, original, 0644)
5958
}
6059

6160
cmd.SetArgs(args) // set the arg for each test case
@@ -86,7 +85,7 @@ var _ = Describe("Edit Command", func() {
8685
})
8786
})
8887

89-
When("edit profile that is not exisiting", func() {
88+
When("edit profile that is not existing", func() {
9089
profileName := "lab.cluster1"
9190
envs := []string{"env1=var1", "env2=var2"}
9291
BeforeEach(func() {

cmd/root_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"testing"
98

@@ -133,8 +132,8 @@ var _ = Describe("Root Command", func() {
133132

134133
// copy if copy is true. otherwise it will be fresh empty config file
135134
if copy {
136-
oiginal, _ := ioutil.ReadFile("../testdata/config.yaml")
137-
ioutil.WriteFile(testConfigFile, oiginal, 0644)
135+
original, _ := os.ReadFile("../testdata/config.yaml")
136+
os.WriteFile(testConfigFile, original, 0644)
138137
}
139138

140139
cmd.SetArgs(args) // set the arg for each test case

cmd/show_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"os"
87

98
. "github.com/onsi/ginkgo/v2"
@@ -53,8 +52,8 @@ var _ = Describe("Show", func() {
5352

5453
// copy if copy is true. otherwise it will be fresh empty config file
5554
if copy {
56-
oiginal, _ := ioutil.ReadFile("../testdata/config.yaml")
57-
ioutil.WriteFile(testConfigFile, oiginal, 0644)
55+
original, _ := os.ReadFile("../testdata/config.yaml")
56+
os.WriteFile(testConfigFile, original, 0644)
5857
}
5958

6059
cmd.SetArgs(args) // set the arg for each test case

cmd/start_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"os"
87

98
. "github.com/onsi/ginkgo/v2"
@@ -67,8 +66,8 @@ var _ = Describe("Start Command", func() {
6766

6867
// copy if copy is true. otherwise it will be fresh empty config file
6968
if copy {
70-
oiginal, _ := ioutil.ReadFile("../testdata/config.yaml")
71-
ioutil.WriteFile(testConfigFile, oiginal, 0644)
69+
original, _ := os.ReadFile("../testdata/config.yaml")
70+
os.WriteFile(testConfigFile, original, 0644)
7271
}
7372

7473
cmd.SetArgs(args) // set the arg for each test case

cmd/use_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"os"
87

98
. "github.com/onsi/ginkgo/v2"
@@ -54,8 +53,8 @@ var _ = Describe("Use", func() {
5453

5554
// copy if copy is true. otherwise it will be fresh empty config file
5655
if copy {
57-
oiginal, _ := ioutil.ReadFile("../testdata/config.yaml")
58-
ioutil.WriteFile(testConfigFile, oiginal, 0644)
56+
original, _ := os.ReadFile("../testdata/config.yaml")
57+
os.WriteFile(testConfigFile, original, 0644)
5958
}
6059

6160
cmd.SetArgs(args) // set the arg for each test case

0 commit comments

Comments
 (0)