Skip to content

Commit

Permalink
all : remove the usage of io/ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
antham committed May 3, 2024
1 parent 1bbafc4 commit ca49c5c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions chyle/apih/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package apih

import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
)
Expand Down Expand Up @@ -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}
}
Expand Down
5 changes: 2 additions & 3 deletions chyle/chyle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package chyle
import (
"bytes"
"encoding/json"
"io/ioutil"
"log"
"os"
"testing"
Expand All @@ -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)
}
Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions chyle/decorators/github_issue_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package decorators

import (
"io/ioutil"
"net/http"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down
6 changes: 3 additions & 3 deletions chyle/senders/github_release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package senders

import (
"fmt"
"io/ioutil"
"net/http"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -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")

Expand Down Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions cmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"bytes"
"io/ioutil"
"io"
"os"
"sync"
"testing"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"bytes"
"io/ioutil"
"io"
"os"
"os/exec"
"sync"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"bytes"
"io/ioutil"
"io"
"os"
"sync"
"testing"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit ca49c5c

Please sign in to comment.