Skip to content

Commit b6e0908

Browse files
authored
Run tests on PR (#57)
* run tests on PR * fix tests+lint * update linter config
1 parent 794a551 commit b6e0908

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

.github/workflows/pr.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ jobs:
1111
- name: Setup Go
1212
uses: actions/setup-go@v2
1313
with:
14-
go-version: '1.18'
14+
go-version: '1.19'
1515
- name: Run vet
1616
run: |
1717
go vet .
1818
- name: Run golangci-lint
1919
uses: golangci/golangci-lint-action@v3
2020
with:
2121
version: latest
22-
# # Run testing on the code
23-
# - name: Run testing
24-
# run: cd test && go test -v
22+
- name: Run tests
23+
run: go test -v .

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,13 @@ linters:
149149
disable-all: true
150150
enable:
151151
## enabled by default
152-
- deadcode # Finds unused code
153152
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
154153
- gosimple # Linter for Go source code that specializes in simplifying a code
155154
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
156155
- ineffassign # Detects when assignments to existing variables are not used
157156
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
158-
- structcheck # Finds unused struct fields
159157
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
160158
- unused # Checks Go code for unused constants, variables, functions and types
161-
- varcheck # Finds unused global variables and constants
162159
## disabled by default
163160
# - asasalint # Check for pass []any as any in variadic func(...any)
164161
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers

api_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99
"log"
1010
"net/http"
1111
"net/http/httptest"
@@ -207,7 +207,7 @@ func TestImages(t *testing.T) {
207207
func getEditBody(r *http.Request) (EditsRequest, error) {
208208
edit := EditsRequest{}
209209
// read the request body
210-
reqBody, err := ioutil.ReadAll(r.Body)
210+
reqBody, err := io.ReadAll(r.Body)
211211
if err != nil {
212212
return EditsRequest{}, err
213213
}
@@ -308,7 +308,7 @@ func handleCompletionEndpoint(w http.ResponseWriter, r *http.Request) {
308308
func getCompletionBody(r *http.Request) (CompletionRequest, error) {
309309
completion := CompletionRequest{}
310310
// read the request body
311-
reqBody, err := ioutil.ReadAll(r.Body)
311+
reqBody, err := io.ReadAll(r.Body)
312312
if err != nil {
313313
return CompletionRequest{}, err
314314
}
@@ -358,7 +358,7 @@ func handleImageEndpoint(w http.ResponseWriter, r *http.Request) {
358358
func getImageBody(r *http.Request) (ImageRequest, error) {
359359
image := ImageRequest{}
360360
// read the request body
361-
reqBody, err := ioutil.ReadAll(r.Body)
361+
reqBody, err := io.ReadAll(r.Body)
362362
if err != nil {
363363
return ImageRequest{}, err
364364
}
@@ -417,7 +417,7 @@ func handleModerationEndpoint(w http.ResponseWriter, r *http.Request) {
417417
func getModerationBody(r *http.Request) (ModerationRequest, error) {
418418
moderation := ModerationRequest{}
419419
// read the request body
420-
reqBody, err := ioutil.ReadAll(r.Body)
420+
reqBody, err := io.ReadAll(r.Body)
421421
if err != nil {
422422
return ModerationRequest{}, err
423423
}

0 commit comments

Comments
 (0)