Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
evsamsonov committed Nov 3, 2023
1 parent 6d40bff commit d893868
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.46.2
version: v1.55.2
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.PHONY: help lint test doc
.DEFAULT_GOAL := help

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

pre-push: lint test ## Run golang lint and test

lint: ## Run golang lint using docker
go mod download
docker run --rm \
-v ${GOPATH}/pkg/mod:/go/pkg/mod \
-v ${PWD}:/app \
-w /app \
golangci/golangci-lint:v1.55.2 \
golangci-lint run -v --modules-download-mode=readonly

test: ## Run tests
go test ./...

doc: ## Run doc server using docker
@echo "Doc server runs on http://127.0.0.1:6060"
docker run --rm \
-p 127.0.0.1:6060:6060 \
-v ${PWD}:/go/src/github.com/evsamsonov/trading-timeseries \
-w /go/src/github.com/evsamsonov/trading-timeseries \
golang:latest \
bash -c "go install golang.org/x/tools/cmd/godoc@latest && /go/bin/godoc -http=:6060"
2 changes: 2 additions & 0 deletions tickseries/tick_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type TickSeries struct {

type Option func(*TickSeries)

// WithAllowZeroIDOption returns Option which sets allowZeroID.
// The default allowZeroID is false
func WithAllowZeroIDOption(allowZeroID bool) Option {
return func(ts *TickSeries) {
ts.allowZeroID = allowZeroID
Expand Down
8 changes: 8 additions & 0 deletions tickseries/tick_series_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ func TestTickSeries_Add(t *testing.T) {
tick3.Time = time.Unix(2, 0)
assert.Equal(t, nil, tickSeries.Add(tick3))
})

t.Run("zero id", func(t *testing.T) {
tickSeries := New(WithAllowZeroIDOption(true))
tick1 := NewTick(1)
tick1.ID = 0
tick1.Time = time.Unix(1, 0)
assert.Equal(t, nil, tickSeries.Add(tick1))
})
}

func TestTickSeries_Tick(t *testing.T) {
Expand Down

0 comments on commit d893868

Please sign in to comment.