Skip to content

Commit

Permalink
replacing mockgen with newer package (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveromahony authored Nov 23, 2023
1 parent b887f38 commit 789f6b1
Show file tree
Hide file tree
Showing 48 changed files with 1,148 additions and 459 deletions.
4 changes: 4 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Copyright (c) F5, Inc.

This source code is licensed under the Apache License, Version 2.0 license found in the
LICENSE file in the root directory of this source tree.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ include Makefile.packaging
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Testing #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
generate-mocks: ## Regenerate all needed mocks, in order to add new mocks generation add //go:generate mockgen to file from witch mocks should be generated
generate-mocks: ## Regenerate all needed mocks, in order to add new mocks generation add //go:generate to file from witch mocks should be generated
GOWORK=off go generate ./...

test: unit-test performance-test component-test integration-test ## Run all tests
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/fsnotify/fsnotify v1.6.0
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.3.1
Expand Down Expand Up @@ -47,6 +46,7 @@ require (
github.com/prometheus/client_golang v1.17.0
github.com/pseudomuto/protoc-gen-doc v1.5.1
github.com/rs/cors v1.10.1
go.uber.org/mock v0.3.0
golang.org/x/sys v0.14.0
golang.org/x/text v0.13.0
gopkg.in/yaml.v2 v2.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down Expand Up @@ -1021,6 +1019,8 @@ go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo=
go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
Expand Down
2 changes: 1 addition & 1 deletion scripts/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
_ "github.com/go-swagger/go-swagger/cmd/swagger"
_ "github.com/gogo/protobuf/protoc-gen-gogo"
_ "github.com/gogo/protobuf/protoc-gen-gogofast"
_ "github.com/golang/mock/mockgen"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/goreleaser/nfpm/v2/cmd/nfpm"
_ "github.com/maxbrunsfeld/counterfeiter/v6"
_ "github.com/mwitkow/go-proto-validators/protoc-gen-govalidators"
_ "github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc"
_ "go.uber.org/mock/mockgen"
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
_ "mvdan.cc/gofumpt"
)
2 changes: 1 addition & 1 deletion src/extensions/advanced-metrics/aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
log "github.com/sirupsen/logrus"
)

//go:generate mockgen -source aggregator.go -destination mocks/aggregator_mock.go -package mocks
//go:generate go run go.uber.org/mock/mockgen -source aggregator.go -destination mocks/aggregator_mock.go -package mocks -copyright_file=../../../../COPYRIGHT

type ReadTable interface {
ReadSnapshot(resetLookups bool) (tables.SamplesView, tables.LookupSet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/nginx/agent/v2/src/extensions/advanced-metrics/aggregator"
"github.com/nginx/agent/v2/src/extensions/advanced-metrics/aggregator/mocks"
"github.com/nginx/agent/v2/src/extensions/advanced-metrics/tables"
Expand All @@ -23,6 +22,7 @@ import (
"github.com/nginx/agent/v2/src/extensions/advanced-metrics/tables/sample"
"github.com/nginx/agent/v2/src/extensions/advanced-metrics/tables/schema"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestAggregatorPublish(t *testing.T) {
Expand Down
23 changes: 13 additions & 10 deletions src/extensions/advanced-metrics/aggregator/mocks/aggregator_mock.go

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

3 changes: 1 addition & 2 deletions src/extensions/advanced-metrics/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
log "github.com/sirupsen/logrus"
)

//go:generate mockgen -source ingester.go -destination mocks/ingester_mock.go -package mocks

//go:generate go run go.uber.org/mock/mockgen -source ingester.go -destination mocks/ingester_mock.go -package mocks -copyright_file=../../../../COPYRIGHT
const workers = 3

type StagingTable interface {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/advanced-metrics/ingester/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"sync"
"testing"

"github.com/golang/mock/gomock"
"github.com/nginx/agent/v2/src/extensions/advanced-metrics/ingester/mocks"
"github.com/nginx/agent/v2/src/extensions/advanced-metrics/reader"
readerMock "github.com/nginx/agent/v2/src/extensions/advanced-metrics/reader/mocks"
"go.uber.org/mock/gomock"
)

func TestIngesterRunCanProcessIncomingData(t *testing.T) {
Expand Down
21 changes: 12 additions & 9 deletions src/extensions/advanced-metrics/ingester/mocks/ingester_mock.go

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

25 changes: 11 additions & 14 deletions src/extensions/advanced-metrics/reader/mocks/net_mocks.go

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

23 changes: 13 additions & 10 deletions src/extensions/advanced-metrics/reader/mocks/reader_mock.go

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

5 changes: 2 additions & 3 deletions src/extensions/advanced-metrics/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import (
"golang.org/x/sync/errgroup"
)

//go:generate mockgen -source reader.go -destination mocks/reader_mock.go -package mocks
//go:generate mockgen -destination mocks/net_mocks.go -build_flags=--mod=mod -package mocks net Listener,Conn

//go:generate go run go.uber.org/mock/mockgen -source reader.go -destination mocks/reader_mock.go -package mocks -copyright_file=../../../../COPYRIGHT
//go:generate go run go.uber.org/mock/mockgen -destination mocks/net_mocks.go -build_flags=--mod=mod -package mocks net Listener,Conn
const (
networkType = "unix"
)
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/advanced-metrics/reader/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"net"
"testing"

"github.com/golang/mock/gomock"
"github.com/nginx/agent/v2/src/extensions/advanced-metrics/reader/mocks"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

const address = "/tmp/advanced-metrics.sr"
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/advanced-metrics/reader/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/nginx/agent/v2/src/extensions/advanced-metrics/reader/mocks"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestWorkerStopAndCloseConnectionOnContexCancelation(t *testing.T) {
Expand Down
Loading

0 comments on commit 789f6b1

Please sign in to comment.