diff --git a/Makefile b/Makefile index 626a8cf..cefb355 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ DOCS_DIR := ./docs OUT_DIR := ./out TESTS_DIR := ./tests +GO_FILES := $(shell find . -type f \( -iname '*.go' ! -path "./tests/semgrep-rules/*" \)) + PB_BUILD_VERSION ?= $(shell git describe --tags) ifeq ($(PB_BUILD_VERSION),) _ := $(error Cannot determine build version) @@ -26,9 +28,9 @@ clean: .PHONY: test test: 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 ./... - gocyclo -over 10 $(shell find . -type f \( -iname '*.go' ! -path "./tests/semgrep-rules/*" \)) + gocyclo -over 10 $(GO_FILES) staticcheck ./... go test -v -cover ./... gosec -exclude-dir=tests ./... @@ -48,7 +50,7 @@ setup: .PHONY: fmt fmt: - gofumpt -l -w . + gofumpt -l -w $(GO_FILES) .PHONY: swag swag: diff --git a/cmd/pushbits/main.go b/cmd/pushbits/main.go index 0be2d82..6d3f4ee 100644 --- a/cmd/pushbits/main.go +++ b/cmd/pushbits/main.go @@ -17,7 +17,7 @@ import ( var version string 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) go func() { diff --git a/internal/api/util_test.go b/internal/api/util_test.go index 3dc2bb8..b89eb55 100644 --- a/internal/api/util_test.go +++ b/internal/api/util_test.go @@ -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 - 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 - 1001", Endpoint: "/", ShouldStatus: 1001} - testCases[nil] = tests.Request{Name: "No Error - 1001", Endpoint: "/", ShouldStatus: 1001} + testCases[nil] = tests.Request{Name: "No Error - 200", Endpoint: "/", ShouldStatus: 200} testCases[nil] = tests.Request{Name: "No Error - 404", Endpoint: "/", ShouldStatus: 404} for forcedErr, testCase := range testCases {