Run tests on PR (#57)
* run tests on PR * fix tests+lint * update linter config
This commit is contained in:
7
.github/workflows/pr.yml
vendored
7
.github/workflows/pr.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '1.18'
|
go-version: '1.19'
|
||||||
- name: Run vet
|
- name: Run vet
|
||||||
run: |
|
run: |
|
||||||
go vet .
|
go vet .
|
||||||
@@ -19,6 +19,5 @@ jobs:
|
|||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
# # Run testing on the code
|
- name: Run tests
|
||||||
# - name: Run testing
|
run: go test -v .
|
||||||
# run: cd test && go test -v
|
|
||||||
|
|||||||
@@ -149,16 +149,13 @@ linters:
|
|||||||
disable-all: true
|
disable-all: true
|
||||||
enable:
|
enable:
|
||||||
## enabled by default
|
## 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
|
- 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
|
- 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
|
- 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
|
- 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
|
- 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
|
- 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
|
- unused # Checks Go code for unused constants, variables, functions and types
|
||||||
- varcheck # Finds unused global variables and constants
|
|
||||||
## disabled by default
|
## disabled by default
|
||||||
# - asasalint # Check for pass []any as any in variadic func(...any)
|
# - 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
|
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
|
||||||
|
|||||||
10
api_test.go
10
api_test.go
@@ -5,7 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@@ -207,7 +207,7 @@ func TestImages(t *testing.T) {
|
|||||||
func getEditBody(r *http.Request) (EditsRequest, error) {
|
func getEditBody(r *http.Request) (EditsRequest, error) {
|
||||||
edit := EditsRequest{}
|
edit := EditsRequest{}
|
||||||
// read the request body
|
// read the request body
|
||||||
reqBody, err := ioutil.ReadAll(r.Body)
|
reqBody, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return EditsRequest{}, err
|
return EditsRequest{}, err
|
||||||
}
|
}
|
||||||
@@ -308,7 +308,7 @@ func handleCompletionEndpoint(w http.ResponseWriter, r *http.Request) {
|
|||||||
func getCompletionBody(r *http.Request) (CompletionRequest, error) {
|
func getCompletionBody(r *http.Request) (CompletionRequest, error) {
|
||||||
completion := CompletionRequest{}
|
completion := CompletionRequest{}
|
||||||
// read the request body
|
// read the request body
|
||||||
reqBody, err := ioutil.ReadAll(r.Body)
|
reqBody, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return CompletionRequest{}, err
|
return CompletionRequest{}, err
|
||||||
}
|
}
|
||||||
@@ -358,7 +358,7 @@ func handleImageEndpoint(w http.ResponseWriter, r *http.Request) {
|
|||||||
func getImageBody(r *http.Request) (ImageRequest, error) {
|
func getImageBody(r *http.Request) (ImageRequest, error) {
|
||||||
image := ImageRequest{}
|
image := ImageRequest{}
|
||||||
// read the request body
|
// read the request body
|
||||||
reqBody, err := ioutil.ReadAll(r.Body)
|
reqBody, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ImageRequest{}, err
|
return ImageRequest{}, err
|
||||||
}
|
}
|
||||||
@@ -417,7 +417,7 @@ func handleModerationEndpoint(w http.ResponseWriter, r *http.Request) {
|
|||||||
func getModerationBody(r *http.Request) (ModerationRequest, error) {
|
func getModerationBody(r *http.Request) (ModerationRequest, error) {
|
||||||
moderation := ModerationRequest{}
|
moderation := ModerationRequest{}
|
||||||
// read the request body
|
// read the request body
|
||||||
reqBody, err := ioutil.ReadAll(r.Body)
|
reqBody, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ModerationRequest{}, err
|
return ModerationRequest{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user