From ca49c5c3eca52136abd634028aa7e61d00ea3adf Mon Sep 17 00:00:00 2001 From: Anthony HAMON Date: Fri, 3 May 2024 23:00:36 +0200 Subject: [PATCH] all : remove the usage of io/ioutil --- chyle/apih/http.go | 4 ++-- chyle/chyle_test.go | 5 ++--- chyle/decorators/github_issue_test.go | 6 +++--- chyle/senders/github_release_test.go | 6 +++--- cmd/config_test.go | 4 ++-- cmd/create_test.go | 4 ++-- cmd/root_test.go | 4 ++-- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/chyle/apih/http.go b/chyle/apih/http.go index d7da3049..f37fb817 100644 --- a/chyle/apih/http.go +++ b/chyle/apih/http.go @@ -2,7 +2,7 @@ package apih import ( "fmt" - "io/ioutil" + "io" "log" "net/http" ) @@ -40,7 +40,7 @@ func SendRequest(client *http.Client, request *http.Request) (int, []byte, error } }() - b, err := ioutil.ReadAll(response.Body) + b, err := io.ReadAll(response.Body) if err != nil { return response.StatusCode, b, errResponse{request, response, b} } diff --git a/chyle/chyle_test.go b/chyle/chyle_test.go index 527755ec..d948941b 100644 --- a/chyle/chyle_test.go +++ b/chyle/chyle_test.go @@ -3,7 +3,6 @@ package chyle import ( "bytes" "encoding/json" - "io/ioutil" "log" "os" "testing" @@ -29,7 +28,7 @@ func TestBuildChangelog(t *testing.T) { setenv("CHYLE_EXTRACTORS_MESSAGE_REG", "(.{1,50})") setenv("CHYLE_SENDERS_STDOUT_FORMAT", "json") - f, err := ioutil.TempFile(p+"/testing-repository", "test") + f, err := os.CreateTemp(p+"/testing-repository", "test") if err != nil { log.Fatal(err) } @@ -54,7 +53,7 @@ func TestBuildChangelog(t *testing.T) { assert.NoError(t, err) - b, err := ioutil.ReadFile(f.Name()) + b, err := os.ReadFile(f.Name()) assert.NoError(t, err) diff --git a/chyle/decorators/github_issue_test.go b/chyle/decorators/github_issue_test.go index 6b4b936b..38730fe1 100644 --- a/chyle/decorators/github_issue_test.go +++ b/chyle/decorators/github_issue_test.go @@ -1,8 +1,8 @@ package decorators import ( - "io/ioutil" "net/http" + "os" "testing" "github.com/stretchr/testify/assert" @@ -30,7 +30,7 @@ func TestGithubIssue(t *testing.T) { defer gock.Off() - issueResponse, err := ioutil.ReadFile("fixtures/github-issue-fetch-response.json") + issueResponse, err := os.ReadFile("fixtures/github-issue-fetch-response.json") assert.NoError(t, err, "Must read json fixture file") @@ -62,7 +62,7 @@ func TestGithubIssue(t *testing.T) { func TestGithubWithNoGithubIssueIdDefined(t *testing.T) { defer gock.Off() - issueResponse, err := ioutil.ReadFile("fixtures/github-issue-fetch-response.json") + issueResponse, err := os.ReadFile("fixtures/github-issue-fetch-response.json") assert.NoError(t, err, "Must read json fixture file") diff --git a/chyle/senders/github_release_test.go b/chyle/senders/github_release_test.go index f58c103e..f0e89415 100644 --- a/chyle/senders/github_release_test.go +++ b/chyle/senders/github_release_test.go @@ -2,8 +2,8 @@ package senders import ( "fmt" - "io/ioutil" "net/http" + "os" "testing" "github.com/stretchr/testify/assert" @@ -23,7 +23,7 @@ func TestGithubReleaseCreateRelease(t *testing.T) { defer gock.Off() - tagCreationResponse, err := ioutil.ReadFile("fixtures/github-tag-creation-response.json") + tagCreationResponse, err := os.ReadFile("fixtures/github-tag-creation-response.json") assert.NoError(t, err, "Must read json fixture file") @@ -105,7 +105,7 @@ func TestGithubReleaseUpdateRelease(t *testing.T) { defer gock.Off() - fetchReleaseResponse, err := ioutil.ReadFile("fixtures/github-release-fetch-response.json") + fetchReleaseResponse, err := os.ReadFile("fixtures/github-release-fetch-response.json") assert.NoError(t, err, "Must read json fixture file") diff --git a/cmd/config_test.go b/cmd/config_test.go index 1d9cf8d1..a5716482 100644 --- a/cmd/config_test.go +++ b/cmd/config_test.go @@ -2,7 +2,7 @@ package cmd import ( "bytes" - "io/ioutil" + "io" "os" "sync" "testing" @@ -43,7 +43,7 @@ func TestConfig(t *testing.T) { wg.Wait() - promptRecord, err := ioutil.ReadAll(writer.(*bytes.Buffer)) + promptRecord, err := io.ReadAll(writer.(*bytes.Buffer)) if err != nil { t.Fatal(err) } diff --git a/cmd/create_test.go b/cmd/create_test.go index 600eacb3..2899f3ac 100644 --- a/cmd/create_test.go +++ b/cmd/create_test.go @@ -2,7 +2,7 @@ package cmd import ( "bytes" - "io/ioutil" + "io" "os" "os/exec" "sync" @@ -121,7 +121,7 @@ func TestCreateWithErrors(t *testing.T) { w.Wait() - output, err := ioutil.ReadAll(writer.(*bytes.Buffer)) + output, err := io.ReadAll(writer.(*bytes.Buffer)) if err != nil { t.Fatal(err) } diff --git a/cmd/root_test.go b/cmd/root_test.go index 3f323cc0..918ab73f 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -2,7 +2,7 @@ package cmd import ( "bytes" - "io/ioutil" + "io" "os" "sync" "testing" @@ -42,7 +42,7 @@ func TestExecute(t *testing.T) { w.Wait() - output, err := ioutil.ReadAll(writer.(*bytes.Buffer)) + output, err := io.ReadAll(writer.(*bytes.Buffer)) if err != nil { t.Fatal(err) }