From b6e0908977b6042f8f64d940dacf5eeb77a1ae51 Mon Sep 17 00:00:00 2001 From: sashabaranov <677093+sashabaranov@users.noreply.github.com> Date: Sat, 28 Jan 2023 22:32:23 +0400 Subject: [PATCH] Run tests on PR (#57) * run tests on PR * fix tests+lint * update linter config --- .github/workflows/pr.yml | 7 +++---- .golangci.yml | 3 --- api_test.go | 10 +++++----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ee77f3c..4928a70 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -11,7 +11,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 with: - go-version: '1.18' + go-version: '1.19' - name: Run vet run: | go vet . @@ -19,6 +19,5 @@ jobs: uses: golangci/golangci-lint-action@v3 with: version: latest - # # Run testing on the code - # - name: Run testing - # run: cd test && go test -v + - name: Run tests + run: go test -v . diff --git a/.golangci.yml b/.golangci.yml index bdf66a8..58fab4a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -149,16 +149,13 @@ linters: disable-all: true enable: ## enabled by default - - deadcode # Finds unused code - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases - gosimple # Linter for Go source code that specializes in simplifying a code - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string - ineffassign # Detects when assignments to existing variables are not used - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks - - structcheck # Finds unused struct fields - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code - unused # Checks Go code for unused constants, variables, functions and types - - varcheck # Finds unused global variables and constants ## disabled by default # - asasalint # Check for pass []any as any in variadic func(...any) - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers diff --git a/api_test.go b/api_test.go index 8848d48..45d888f 100644 --- a/api_test.go +++ b/api_test.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "net/http" "net/http/httptest" @@ -207,7 +207,7 @@ func TestImages(t *testing.T) { func getEditBody(r *http.Request) (EditsRequest, error) { edit := EditsRequest{} // read the request body - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { return EditsRequest{}, err } @@ -308,7 +308,7 @@ func handleCompletionEndpoint(w http.ResponseWriter, r *http.Request) { func getCompletionBody(r *http.Request) (CompletionRequest, error) { completion := CompletionRequest{} // read the request body - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { return CompletionRequest{}, err } @@ -358,7 +358,7 @@ func handleImageEndpoint(w http.ResponseWriter, r *http.Request) { func getImageBody(r *http.Request) (ImageRequest, error) { image := ImageRequest{} // read the request body - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { return ImageRequest{}, err } @@ -417,7 +417,7 @@ func handleModerationEndpoint(w http.ResponseWriter, r *http.Request) { func getModerationBody(r *http.Request) (ModerationRequest, error) { moderation := ModerationRequest{} // read the request body - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { return ModerationRequest{}, err }