Skip to content

Commit

Permalink
Merge pull request #75 from americanas-tech/static-check
Browse files Browse the repository at this point in the history
Remove deprecated ioutil
  • Loading branch information
rodrigodc07 authored Jul 17, 2023
2 parents ff30228 + 94d8fdc commit 62d379c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 42 deletions.
26 changes: 12 additions & 14 deletions internal/parser/ast/grammar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions internal/platform/conf/conf.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package conf

import (
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -167,7 +166,7 @@ func readConfigFile() []byte {
return nil
}

data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
if err != nil {
log.Printf("[ERROR] could not load file at %s", path)
return nil
Expand Down
4 changes: 2 additions & 2 deletions internal/platform/persistence/mappings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"
"github.com/b2wdigital/restQL-golang/v6/pkg/restql"
"io/ioutil"
"io"
"testing"

"github.com/b2wdigital/restQL-golang/v6/internal/platform/logger"
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestMappingsReader_ShouldOverwriteMappings(t *testing.T) {
test.Equal(t, mappings, expected)
}

var noOpLogger = logger.New(ioutil.Discard, logger.LogOptions{})
var noOpLogger = logger.New(io.Discard, logger.LogOptions{})

type stubDatabase struct {
findMappingsForTenant []restql.Mapping
Expand Down
7 changes: 3 additions & 4 deletions test/e2e/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"github.com/b2wdigital/restQL-golang/v6/test"
"io"
"io/ioutil"
"net/http"
"strings"
"testing"
Expand Down Expand Up @@ -223,7 +222,7 @@ to planets as sats in planets.sats
mockServer.Mux().HandleFunc("/api/planets/Havoc", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

test.NotEqual(t, string(b), "")
Expand Down Expand Up @@ -347,7 +346,7 @@ into planets as sats in planets.sats
mockServer.Mux().HandleFunc("/api/planets/Havoc", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPut)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

test.NotEqual(t, string(b), "")
Expand Down Expand Up @@ -471,7 +470,7 @@ update planets as sats in planets.sats
mockServer.Mux().HandleFunc("/api/planets/Havoc", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPatch)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

test.NotEqual(t, string(b), "")
Expand Down
9 changes: 4 additions & 5 deletions test/e2e/chained_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -255,7 +254,7 @@ to people
mockServer.Mux().HandleFunc("/api/people/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

test.NotEqual(t, string(b), "")
Expand Down Expand Up @@ -354,7 +353,7 @@ into people
mockServer.Mux().HandleFunc("/api/people/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPut)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

test.NotEqual(t, string(b), "")
Expand Down Expand Up @@ -453,7 +452,7 @@ update people
mockServer.Mux().HandleFunc("/api/people/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPatch)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

test.NotEqual(t, string(b), "")
Expand Down Expand Up @@ -944,7 +943,7 @@ from people
test.VerifyError(t, err)
defer response.Body.Close()

//bytes, err := ioutil.ReadAll(response.Body)
//bytes, err := io.ReadAll(response.Body)
//test.VerifyError(t, err)

//fmt.Printf("response : %s\n", string(bytes))
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -180,7 +179,7 @@ func TestVariableResolutionUsingHeadersOnFromStatement(t *testing.T) {
})
mockServer.Start()

request, err := http.NewRequest(http.MethodGet, savedQueryUrl, ioutil.NopCloser(strings.NewReader("")))
request, err := http.NewRequest(http.MethodGet, savedQueryUrl, io.NopCloser(strings.NewReader("")))
test.VerifyError(t, err)

request.Header["name"] = []string{"Yavin"}
Expand Down Expand Up @@ -233,7 +232,7 @@ func TestVariableResolutionUsingQueryParametersOnToStatement(t *testing.T) {
mockServer.Mux().HandleFunc("/api/planets/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down
23 changes: 11 additions & 12 deletions test/e2e/with_qualifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -182,7 +181,7 @@ to planets
mockServer.Mux().HandleFunc("/api/planets/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down Expand Up @@ -263,7 +262,7 @@ into planets
mockServer.Mux().HandleFunc("/api/planets/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPut)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down Expand Up @@ -344,7 +343,7 @@ update planets
mockServer.Mux().HandleFunc("/api/planets/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPatch)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down Expand Up @@ -742,7 +741,7 @@ to planets
mockServer.Mux().HandleFunc("/api/planets/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down Expand Up @@ -829,7 +828,7 @@ to planets
mockServer.Mux().HandleFunc("/api/planets/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

test.NotEqual(t, string(b), "")
Expand Down Expand Up @@ -919,7 +918,7 @@ to planets
mockServer.Mux().HandleFunc("/api/planets/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down Expand Up @@ -990,7 +989,7 @@ to planets
mockServer.Mux().HandleFunc("/api/planets/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down Expand Up @@ -1055,7 +1054,7 @@ to planets
mockServer.Mux().HandleFunc("/api/planets/", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down Expand Up @@ -1143,7 +1142,7 @@ to planets
mockServer.Mux().HandleFunc("/api/planets/Yavin", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand All @@ -1157,7 +1156,7 @@ to planets
mockServer.Mux().HandleFunc("/api/planets/Tatooine", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down Expand Up @@ -1294,7 +1293,7 @@ to planets
mockServer.Mux().HandleFunc("/api/planets/1", func(w http.ResponseWriter, r *http.Request) {
test.Equal(t, r.Method, http.MethodPost)

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
test.VerifyError(t, err)

body := string(b)
Expand Down

0 comments on commit 62d379c

Please sign in to comment.