Skip to content

Commit

Permalink
fix: remove deprecated ioutil package given go new version (#1017)
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Heath <76011913+jakeyheath@users.noreply.github.com>
  • Loading branch information
kuannie1 and jakeyheath committed Apr 26, 2024
1 parent d832a3c commit 44388ff
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions plugins/custom_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"compress/gzip"
"fmt"
"io"
"io/ioutil"

"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -78,7 +77,7 @@ func TestCustomPluginTarStripComponents(t *testing.T) {
r.NoError(err)
defer os.RemoveAll(d)

cacheDir, err := ioutil.TempDir("", "")
cacheDir, err := os.MkdirTemp("", "")
r.NoError(err)
defer os.RemoveAll(cacheDir)
cache := plugins.GetPluginCache(cacheDir)
Expand Down Expand Up @@ -139,7 +138,7 @@ func TestCustomPluginZip(t *testing.T) {
r.NoError(err)
defer os.RemoveAll(d)

cacheDir, err := ioutil.TempDir("", "")
cacheDir, err := os.MkdirTemp("", "")
r.NoError(err)
defer os.RemoveAll(cacheDir)
cache := plugins.GetPluginCache(cacheDir)
Expand Down Expand Up @@ -189,7 +188,7 @@ func TestCustomPluginBin(t *testing.T) {
defer os.RemoveAll(d)
fileContents := "some contents"

cacheDir, err := ioutil.TempDir("", "")
cacheDir, err := os.MkdirTemp("", "")
r.NoError(err)
defer os.RemoveAll(cacheDir)
cache := plugins.GetPluginCache(cacheDir)
Expand Down Expand Up @@ -220,7 +219,7 @@ func TestCustomPluginBin(t *testing.T) {
f, err := fs.Open(customPluginPath)
r.Nil(err)

contents, err := ioutil.ReadAll(f)
contents, err := io.ReadAll(f)
r.Nil(err)
r.Equal(string(contents), fileContents)

Expand All @@ -233,7 +232,7 @@ func TestCustomPluginBin(t *testing.T) {
func generateTar(t *testing.T, files []string, dirs []string) string {
r := require.New(t)

f, err := ioutil.TempFile("", "testing")
f, err := os.CreateTemp("", "testing")
r.Nil(err)
defer f.Close()
gw := gzip.NewWriter(f)
Expand Down Expand Up @@ -269,7 +268,7 @@ func generateTar(t *testing.T, files []string, dirs []string) string {
// based on https://golangcode.com/create-zip-files-in-go/
func generateZip(t *testing.T, files []string) string {
r := require.New(t)
f, err := ioutil.TempFile("", "testing")
f, err := os.CreateTemp("", "testing")
r.Nil(err)

defer f.Close()
Expand Down

0 comments on commit 44388ff

Please sign in to comment.