mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-21 14:50:53 -08:00
refactor: move from io/ioutil to io and os package (#1245)
The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -377,7 +377,7 @@ func TestRun_WithTar(t *testing.T) {
|
||||
|
||||
// Setup CLI App
|
||||
app := commands.NewApp("dev")
|
||||
app.Writer = ioutil.Discard
|
||||
app.Writer = io.Discard
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
@@ -402,7 +402,7 @@ func TestRun_WithTar(t *testing.T) {
|
||||
}
|
||||
if len(c.testArgs.IgnoreIDs) != 0 {
|
||||
trivyIgnore := ".trivyignore"
|
||||
err := ioutil.WriteFile(trivyIgnore, []byte(strings.Join(c.testArgs.IgnoreIDs, "\n")), 0444)
|
||||
err := os.WriteFile(trivyIgnore, []byte(strings.Join(c.testArgs.IgnoreIDs, "\n")), 0444)
|
||||
assert.NoError(t, err, "failed to write .trivyignore")
|
||||
defer os.Remove(trivyIgnore)
|
||||
}
|
||||
@@ -427,7 +427,7 @@ func TestRun_WithTar(t *testing.T) {
|
||||
if *update {
|
||||
outputFile = c.golden
|
||||
} else {
|
||||
output, _ := ioutil.TempFile("", "integration")
|
||||
output, _ := os.CreateTemp("", "integration")
|
||||
assert.Nil(t, output.Close())
|
||||
defer os.Remove(output.Name())
|
||||
outputFile = output.Name()
|
||||
@@ -439,9 +439,9 @@ func TestRun_WithTar(t *testing.T) {
|
||||
assert.Nil(t, app.Run(osArgs))
|
||||
|
||||
// Compare want and got
|
||||
want, err := ioutil.ReadFile(c.golden)
|
||||
want, err := os.ReadFile(c.golden)
|
||||
assert.NoError(t, err)
|
||||
got, err := ioutil.ReadFile(outputFile)
|
||||
got, err := os.ReadFile(outputFile)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.JSONEq(t, string(want), string(got))
|
||||
|
||||
Reference in New Issue
Block a user