Skip to content

Commit

Permalink
Fix test & lint (#11)
Browse files Browse the repository at this point in the history
* Fix test

* Update golangci lint
  • Loading branch information
evsamsonov authored Jun 23, 2023
1 parent 99868d3 commit 771e135
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 5 deletions.
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.49.0
version: v1.53.3
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lint:
-v ${GOPATH}/pkg/mod:/go/pkg/mod \
-v ${PWD}:/app \
-w /app \
golangci/golangci-lint:v1.49.0 \
golangci/golangci-lint:v1.53.3 \
golangci-lint run -v --modules-download-mode=readonly

test:
Expand Down
124 changes: 124 additions & 0 deletions mock_broker_runner.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions trengin.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ type Strategy interface {
// Неожиданные типы приведут к ошибке и завершению работы Engine
type Actions chan interface{}

//go:generate docker run --rm -v ${PWD}:/app -w /app/ vektra/mockery --name BrokerRunner --inpackage --case snake
type BrokerRunner interface {
Broker
Runner
}

//go:generate docker run --rm -v ${PWD}:/app -w /app/ vektra/mockery --name Broker --inpackage --case snake

// Broker describes client for execution of trading operations.
Expand Down
6 changes: 3 additions & 3 deletions trengin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func TestEngine_doChangeConditionalOrder(t *testing.T) {
func TestEngine_Run(t *testing.T) {
t.Run("context canceled", func(t *testing.T) {
strategy := &MockStrategy{}
broker := &MockBroker{}
broker := &MockBrokerRunner{}
ctx, cancel := context.WithCancel(context.Background())

strategy.On("Run", mock.Anything, mock.Anything).After(100 * time.Millisecond).Return(nil)
Expand All @@ -429,7 +429,7 @@ func TestEngine_Run(t *testing.T) {

t.Run("error received", func(t *testing.T) {
strategy := &MockStrategy{}
broker := &MockBroker{}
broker := &MockBrokerRunner{}
ctx := context.Background()

strategy.On("Run", mock.Anything, mock.Anything).After(1000 * time.Millisecond).Return(nil)
Expand All @@ -455,7 +455,7 @@ func TestEngine_Run(t *testing.T) {

t.Run("unknown action", func(t *testing.T) {
strategy := &MockStrategy{}
broker := &MockBroker{}
broker := &MockBrokerRunner{}
ctx := context.Background()

strategy.On("Run", mock.Anything, mock.MatchedBy(func(actions Actions) bool {
Expand Down

0 comments on commit 771e135

Please sign in to comment.