Fix tests after Go update

This commit is contained in:
eikendev 2022-04-20 22:38:10 +02:00
parent 0b8d22d293
commit ed78c18c24
No known key found for this signature in database
GPG key ID: A1BDB1B28C8EF694
3 changed files with 7 additions and 6 deletions

View file

@ -5,6 +5,8 @@ DOCS_DIR := ./docs
OUT_DIR := ./out OUT_DIR := ./out
TESTS_DIR := ./tests TESTS_DIR := ./tests
GO_FILES := $(shell find . -type f \( -iname '*.go' ! -path "./tests/semgrep-rules/*" \))
PB_BUILD_VERSION ?= $(shell git describe --tags) PB_BUILD_VERSION ?= $(shell git describe --tags)
ifeq ($(PB_BUILD_VERSION),) ifeq ($(PB_BUILD_VERSION),)
_ := $(error Cannot determine build version) _ := $(error Cannot determine build version)
@ -26,9 +28,9 @@ clean:
.PHONY: test .PHONY: test
test: test:
touch $(SEMGREP_MODFILE) # See [1]. touch $(SEMGREP_MODFILE) # See [1].
stdout=$$(gofumpt -l . 2>&1); if [ "$$stdout" ]; then exit 1; fi stdout=$$(gofumpt -l $(GO_FILES) 2>&1); if [ "$$stdout" ]; then exit 1; fi
go vet ./... go vet ./...
gocyclo -over 10 $(shell find . -type f \( -iname '*.go' ! -path "./tests/semgrep-rules/*" \)) gocyclo -over 10 $(GO_FILES)
staticcheck ./... staticcheck ./...
go test -v -cover ./... go test -v -cover ./...
gosec -exclude-dir=tests ./... gosec -exclude-dir=tests ./...
@ -48,7 +50,7 @@ setup:
.PHONY: fmt .PHONY: fmt
fmt: fmt:
gofumpt -l -w . gofumpt -l -w $(GO_FILES)
.PHONY: swag .PHONY: swag
swag: swag:

View file

@ -17,7 +17,7 @@ import (
var version string var version string
func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) { func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) {
c := make(chan os.Signal) c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM) signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() { go func() {

View file

@ -19,8 +19,7 @@ func TestApi_SuccessOrAbort(t *testing.T) {
testCases[errors.New("this is an error")] = tests.Request{Name: "Error - 500", Endpoint: "/", ShouldStatus: 500} testCases[errors.New("this is an error")] = tests.Request{Name: "Error - 500", Endpoint: "/", ShouldStatus: 500}
testCases[errors.New("this is an error")] = tests.Request{Name: "Error - 200", Endpoint: "/", ShouldStatus: 200} testCases[errors.New("this is an error")] = tests.Request{Name: "Error - 200", Endpoint: "/", ShouldStatus: 200}
testCases[errors.New("this is an error")] = tests.Request{Name: "Error - 404", Endpoint: "/", ShouldStatus: 404} testCases[errors.New("this is an error")] = tests.Request{Name: "Error - 404", Endpoint: "/", ShouldStatus: 404}
testCases[errors.New("this is an error")] = tests.Request{Name: "Error - 1001", Endpoint: "/", ShouldStatus: 1001} testCases[nil] = tests.Request{Name: "No Error - 200", Endpoint: "/", ShouldStatus: 200}
testCases[nil] = tests.Request{Name: "No Error - 1001", Endpoint: "/", ShouldStatus: 1001}
testCases[nil] = tests.Request{Name: "No Error - 404", Endpoint: "/", ShouldStatus: 404} testCases[nil] = tests.Request{Name: "No Error - 404", Endpoint: "/", ShouldStatus: 404}
for forcedErr, testCase := range testCases { for forcedErr, testCase := range testCases {