Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dehort committed Dec 10, 2024
1 parent ef2de0d commit 8068761
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 34 deletions.
4 changes: 2 additions & 2 deletions internal/api/middleware/pskAuth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package middleware
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"playbook-dispatcher/internal/common/utils"
Expand Down Expand Up @@ -76,7 +76,7 @@ var _ = Describe("PSK auth middleware", func() {
res, err := testPskAuth(req)
Expect(err).ToNot(HaveOccurred())
Expect(res.Result().StatusCode).To(Equal(200))
body, err := ioutil.ReadAll(res.Result().Body)
body, err := io.ReadAll(res.Result().Body)
Expect(err).ToNot(HaveOccurred())
Expect(body).To(BeEquivalentTo("principal1"))
})
Expand Down
13 changes: 6 additions & 7 deletions internal/api/tests/private/client.gen.go

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

4 changes: 2 additions & 2 deletions internal/api/tests/private/runsCreateV1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package private

import (
"context"
"io/ioutil"
"io"
"net/http"
"playbook-dispatcher/internal/api/controllers/public"
dbModel "playbook-dispatcher/internal/common/model/db"
Expand Down Expand Up @@ -212,7 +212,7 @@ var _ = Describe("runsCreate V1", func() {
resp, err := client.ApiInternalRunsCreateWithBody(test.TestContext(), "application/json", strings.NewReader(payload))
Expect(err).ToNot(HaveOccurred())
Expect(resp.StatusCode).To(Equal(http.StatusBadRequest))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
Expect(err).ToNot(HaveOccurred())
Expect(string(body)).To(ContainSubstring(expected))
},
Expand Down
4 changes: 2 additions & 2 deletions internal/api/tests/private/runsCreateV2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package private

import (
"context"
"io/ioutil"
"io"
"net/http"
"playbook-dispatcher/internal/api/controllers/public"
dbModel "playbook-dispatcher/internal/common/model/db"
Expand Down Expand Up @@ -318,7 +318,7 @@ var _ = Describe("runsCreate V2", func() {
resp, err := client.ApiInternalV2RunsCreateWithBody(test.TestContext(), "application/json", strings.NewReader(payload))
Expect(err).ToNot(HaveOccurred())
Expect(resp.StatusCode).To(Equal(http.StatusBadRequest))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
Expect(err).ToNot(HaveOccurred())
Expect(string(body)).To(ContainSubstring(expected))
},
Expand Down
4 changes: 2 additions & 2 deletions internal/api/tests/private/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package private

import (
"bytes"
"io/ioutil"
"io"
"net/http"

"playbook-dispatcher/internal/common/utils/test"
Expand All @@ -22,7 +22,7 @@ var _ = Describe("Version", func() {
Expect(err).ToNot(HaveOccurred())
Expect(res.StatusCode).To(Equal(http.StatusOK))

data, err := ioutil.ReadAll(res.Body)
data, err := io.ReadAll(res.Body)
Expect(err).ToNot(HaveOccurred())

// Remove quotes and newline from the returned data
Expand Down
6 changes: 3 additions & 3 deletions internal/api/tests/public/client.gen.go

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

4 changes: 2 additions & 2 deletions internal/api/tests/public/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package public
import (
"bytes"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"playbook-dispatcher/internal/common/utils/test"

Expand Down Expand Up @@ -59,7 +59,7 @@ var _ = Describe("Middleware", func() {
Expect(err).ToNot(HaveOccurred())

Expect(res.StatusCode).To(Equal(http.StatusBadRequest))
data, _ := ioutil.ReadAll(res.Body)
data, _ := io.ReadAll(res.Body)
defer res.Body.Close()

Expect(data).To(BeEquivalentTo("Bad Request: missing x-rh-identity header\n"))
Expand Down
4 changes: 2 additions & 2 deletions internal/api/tests/public/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package public

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"playbook-dispatcher/internal/common/utils"
"playbook-dispatcher/internal/common/utils/test"
Expand All @@ -16,7 +16,7 @@ func fieldTester(fn func(params ...interface{}) *http.Response) func(...string)
res := fn(params...)
Expect(res.StatusCode).To(Equal(http.StatusOK))

bodyBytes, err := ioutil.ReadAll(res.Body)
bodyBytes, err := io.ReadAll(res.Body)
Expect(err).ToNot(HaveOccurred())
defer res.Body.Close()

Expand Down
4 changes: 2 additions & 2 deletions internal/common/ansible/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package ansible

import (
"encoding/json"
"io/ioutil"
messageModel "playbook-dispatcher/internal/common/model/message"
"os"
"strings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func loadFile(path string) (events []messageModel.PlaybookRunResponseMessageYamlEventsElem) {
file, err := ioutil.ReadFile(path)
file, err := os.ReadFile(path)
Expect(err).ToNot(HaveOccurred())

lines := strings.Split(string(file), "\n")
Expand Down
4 changes: 2 additions & 2 deletions internal/common/satellite/satellite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package satellite

import (
"encoding/json"
"io/ioutil"
messageModel "playbook-dispatcher/internal/common/model/message"
"os"
"strings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func loadFile(path string) (events []messageModel.PlaybookSatRunResponseMessageYamlEventsElem) {
file, err := ioutil.ReadFile(path)
file, err := os.ReadFile(path)
Expect(err).ToNot(HaveOccurred())

lines := strings.Split(string(file), "\n")
Expand Down
4 changes: 2 additions & 2 deletions internal/common/utils/test/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package test

import (
"bytes"
"io/ioutil"
"io"
"net/http"
)

Expand All @@ -19,7 +19,7 @@ func (this *mockHttpRequestDoer) Do(req *http.Request) (*http.Response, error) {
func MockHttpClient(statusCode int, body string) mockHttpRequestDoer {
response := http.Response{
StatusCode: statusCode,
Body: ioutil.NopCloser(bytes.NewReader([]byte(body))),
Body: io.NopCloser(bytes.NewReader([]byte(body))),
Header: http.Header{
"Content-Type": []string{"application/json"},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/common/utils/test/multiResponseClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package test

import (
"bytes"
"io/ioutil"
"io"
"net/http"
)

Expand Down Expand Up @@ -31,7 +31,7 @@ func MockMultiResponseHttpClient(mockResponses ...MockHttpResponse) *mockMultiRe
for i := range mockResponses {
response := http.Response{
StatusCode: mockResponses[i].StatusCode,
Body: ioutil.NopCloser(bytes.NewReader([]byte(mockResponses[i].Body))),
Body: io.NopCloser(bytes.NewReader([]byte(mockResponses[i].Body))),
Header: http.Header{
"Content-Type": []string{"application/json"},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/validator/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/base64"
"encoding/json"
"io/ioutil"
"os"
"playbook-dispatcher/internal/common/constants"
kafkaUtils "playbook-dispatcher/internal/common/kafka"
messageModel "playbook-dispatcher/internal/common/model/message"
Expand All @@ -27,7 +27,7 @@ var _ = Describe("Handler", func() {

for _, filePath := range []string{"../../schema/ansibleRunnerJobEvent.yaml", "../../schema/rhcsatJobEvent.yaml"} {
var schema jsonschema.Schema
file, err := ioutil.ReadFile(filePath)
file, err := os.ReadFile(filePath)
Expect(err).ToNot(HaveOccurred())
err = yaml.Unmarshal(file, &schema)
Expect(err).ToNot(HaveOccurred())
Expand Down
3 changes: 1 addition & 2 deletions internal/validator/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"compress/gzip"
"io"
"io/ioutil"
"net/http"
commonInstrumentation "playbook-dispatcher/internal/common/instrumentation"
"playbook-dispatcher/internal/common/utils"
Expand Down Expand Up @@ -98,5 +97,5 @@ func readFile(reader io.Reader) (result []byte, err error) {
}
}

return ioutil.ReadAll(reader)
return io.ReadAll(reader)
}

0 comments on commit 8068761

Please sign in to comment.