Skip to content

Commit

Permalink
Fix golangci-lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-abtasty committed Aug 17, 2022
1 parent 21ac4f8 commit 0217c42
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
run: go test -race -coverpkg=./... ./... -coverprofile cover.out.tmp -covermode=atomic
- name: Removes mocks from tests
run: cat cover.out.tmp | grep -v "_mock.go" > cover.out
# - name: golangci-lint
# uses: golangci/golangci-lint-action@v2
# with:
# # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
# version: v1.48
# args: --skip-files .*_test.go
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.48
args: --skip-files .*_test.go
- uses: codecov/codecov-action@v2
with:
file: ./cover.out
Expand Down
4 changes: 2 additions & 2 deletions pkg/connectors/environment_loaders/cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package environment_loaders

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"sync"
"time"
Expand Down Expand Up @@ -116,7 +116,7 @@ func (l *CDNLoader) fetchEnvironment(envID string, APIKey string) error {
return nil
}

response, err := ioutil.ReadAll(resp.Body)
response, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("error when reading body: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/connectors/hits_processors/datacollect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package hits_processors

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"sync"
Expand Down Expand Up @@ -36,7 +36,7 @@ func TestDataCollectTrack(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
// Send response to be tested
lock.Lock()
lastBodySent, _ := ioutil.ReadAll(req.Body)
lastBodySent, _ := io.ReadAll(req.Body)
bodySents = append(bodySents, string(lastBodySent))
_, err := rw.Write([]byte("{}"))
assert.Nil(t, err)
Expand Down
5 changes: 2 additions & 3 deletions pkg/handlers/activate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package handlers

import (
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -33,7 +32,7 @@ func TestActivate(t *testing.T) {
Activate(context)(w, req)

resp := w.Result()
bodyResp, _ := ioutil.ReadAll(resp.Body)
bodyResp, _ := io.ReadAll(resp.Body)
assert.Equal(t, 400, resp.StatusCode)
assert.Contains(t, string(bodyResp), "unknown field")

Expand All @@ -50,7 +49,7 @@ func TestActivate(t *testing.T) {
Activate(context)(w, req)

resp = w.Result()
bodyResp, _ = ioutil.ReadAll(resp.Body)
bodyResp, _ = io.ReadAll(resp.Body)
assert.Equal(t, 400, resp.StatusCode)
assert.Contains(t, string(bodyResp), "Field is mandatory")

Expand Down
10 changes: 5 additions & 5 deletions pkg/handlers/campaign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestSendSingleFormatResponse(t *testing.T) {
resp := w.Result()
assert.Equal(t, 200, resp.StatusCode)
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
assert.Contains(t, string(body), `"variation":`)

// other modification type returns json format
Expand All @@ -104,7 +104,7 @@ func TestSendSingleFormatResponse(t *testing.T) {
resp = w.Result()
assert.Equal(t, 200, resp.StatusCode)
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
body, _ = ioutil.ReadAll(resp.Body)
body, _ = io.ReadAll(resp.Body)
assert.Contains(t, string(body), `"variation":`)

// html type with single fields returns text/html with html value
Expand All @@ -117,7 +117,7 @@ func TestSendSingleFormatResponse(t *testing.T) {
assert.Equal(t, 200, resp.StatusCode)
assert.Equal(t, "text/html", resp.Header.Get("Content-Type"))

body, _ = ioutil.ReadAll(resp.Body)
body, _ = io.ReadAll(resp.Body)
assert.Equal(t, "value", string(body))

// text type with single fields returns text/plain withs stringified bool value
Expand All @@ -130,7 +130,7 @@ func TestSendSingleFormatResponse(t *testing.T) {
assert.Equal(t, 200, resp.StatusCode)
assert.Equal(t, "text/plain", resp.Header.Get("Content-Type"))

body, _ = ioutil.ReadAll(resp.Body)
body, _ = io.ReadAll(resp.Body)
assert.Equal(t, "true", string(body))

// text type with single fields returns text/plain withs stringified number value
Expand All @@ -139,6 +139,6 @@ func TestSendSingleFormatResponse(t *testing.T) {
sendSingleFormatResponse(w, campaign, logger.New("debug", "test"))

resp = w.Result()
body, _ = ioutil.ReadAll(resp.Body)
body, _ = io.ReadAll(resp.Body)
assert.Equal(t, "20.5", string(body))
}

0 comments on commit 0217c42

Please sign in to comment.