Skip to content

Commit

Permalink
fix: remove usage of io/ioutil
Browse files Browse the repository at this point in the history
Signed-off-by: ismael FALL <ismael.fall@epitech.eu>
  • Loading branch information
Doozers committed Mar 17, 2023
1 parent ca6b73e commit 3beda07
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
12 changes: 6 additions & 6 deletions internal/dvcore/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package dvcore

import (
"bytes"
"io/ioutil"
"os"
"testing"

"github.com/cayleygraph/cayley/graph"
"github.com/cayleygraph/quad"
"github.com/stretchr/testify/assert"
"moul.io/depviz/v3/internal/dvstore"
"moul.io/depviz/v3/internal/testutil"
"moul.io/multipmuri"

"github.com/cayleygraph/cayley/graph"
"github.com/cayleygraph/quad"
"github.com/stretchr/testify/assert"
)

func TestPullAndSave(t *testing.T) {
Expand Down Expand Up @@ -82,11 +82,11 @@ func TestPullAndSave(t *testing.T) {
gp := dvstore.TestingGoldenDumpPath(t, test.name)
if testutil.UpdateGolden() {
t.Logf("update golden file: %s", gp)
err := ioutil.WriteFile(gp, b.Bytes(), 0644)
err := os.WriteFile(gp, b.Bytes(), 0644)
assert.NoError(t, err, test.name)
}

g, err := ioutil.ReadFile(gp)
g, err := os.ReadFile(gp)
assert.NoError(t, err, test.name)
assert.Equal(t, string(g), b.String())
}
Expand Down
6 changes: 3 additions & 3 deletions internal/dvserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"encoding/base64"
"fmt"
"io/ioutil"
"io"
"net/http"

"go.uber.org/zap"
Expand All @@ -24,7 +24,7 @@ func gitHubOAuth(opts Opts, httpLogger *zap.Logger) http.HandlerFunc {
return
}

code, err := ioutil.ReadAll(r.Body)
code, err := io.ReadAll(r.Body)
if err != nil {
httpLogger.Error("get body", zap.Error(err))
http.Error(w, "failed to retrieve body", http.StatusInternalServerError)
Expand Down Expand Up @@ -63,7 +63,7 @@ func gitHubOAuth(opts Opts, httpLogger *zap.Logger) http.HandlerFunc {

defer gitHubResponse.Body.Close()

token, err := ioutil.ReadAll(gitHubResponse.Body)
token, err := io.ReadAll(gitHubResponse.Body)
if err != nil {
httpLogger.Error("get body", zap.Error(err))
http.Error(w, "internal server error", http.StatusInternalServerError)
Expand Down
7 changes: 4 additions & 3 deletions internal/dvstore/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"sort"
"time"

"go.uber.org/zap"
"moul.io/depviz/v3/internal/dvmodel"
"moul.io/multipmuri"

"github.com/cayleygraph/cayley"
"github.com/cayleygraph/cayley/graph/path"
"github.com/cayleygraph/cayley/schema"
"github.com/cayleygraph/quad"
"go.uber.org/zap"
"moul.io/depviz/v3/internal/dvmodel"
"moul.io/multipmuri"
)

func LastUpdatedIssueInRepo(ctx context.Context, h *cayley.Handle, entity multipmuri.Entity) (time.Time, error) { // nolint:interfacer
Expand Down
11 changes: 6 additions & 5 deletions internal/dvstore/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package dvstore

import (
"fmt"
"io/ioutil"
"os"
"strings"
"testing"

_ "github.com/cayleygraph/quad/json"
"github.com/stretchr/testify/assert"
"moul.io/depviz/v3/internal/dvparser"
"moul.io/depviz/v3/internal/testutil"
"moul.io/godev"
"moul.io/multipmuri"

_ "github.com/cayleygraph/quad/json"
"github.com/stretchr/testify/assert"
)

func TestLoadTasks(t *testing.T) {
Expand Down Expand Up @@ -62,7 +63,7 @@ func TestLoadTasks(t *testing.T) {

if testutil.UpdateGolden() {
t.Logf("update golden file: %s", gp)
err := ioutil.WriteFile(gp, []byte(actual), 0644)
err := os.WriteFile(gp, []byte(actual), 0644)
assert.NoError(t, err, name)
}

Expand All @@ -82,7 +83,7 @@ func TestLoadTasks(t *testing.T) {
}
}

g, err := ioutil.ReadFile(gp)
g, err := os.ReadFile(gp)
assert.NoError(t, err, name)
assert.Equal(t, len(string(g)), len(actual), gp)
})
Expand Down
3 changes: 1 addition & 2 deletions internal/dvstore/testing.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dvstore

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -78,7 +77,7 @@ func TestingGoldenStore(t *testing.T, name string) (*cayley.Handle, func()) {
func TestingStore(t *testing.T) (*cayley.Handle, func()) {
t.Helper()

dir, err := ioutil.TempDir("", "depviz")
dir, err := os.MkdirTemp("", "depviz")
require.NoError(t, err)

err = graph.InitQuadStore("bolt", dir, nil)
Expand Down

0 comments on commit 3beda07

Please sign in to comment.