From 4274e67b47d404570d1c7b96cb6daa0cbf5f77c9 Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" <4903+rboyer@users.noreply.github.com> Date: Thu, 21 Apr 2022 09:48:21 -0500 Subject: [PATCH] chore: upgrade mockery to v2 and regenerate (#12836) --- GNUmakefile | 2 +- agent/cache-types/mock_RPC.go | 18 ++++++++++++++++-- agent/cache-types/rpc.go | 2 +- agent/cache/cache.go | 2 +- agent/cache/mock_Request.go | 17 +++++++++++++++-- agent/cache/mock_Type.go | 17 +++++++++++++++-- agent/connect/ca/mock_Provider.go | 15 +++++++++++++-- agent/connect/ca/provider.go | 2 +- .../autopilotevents/mock_Publisher_test.go | 13 ++++++++++++- .../autopilotevents/mock_StateStore_test.go | 13 ++++++++++++- .../autopilotevents/mock_timeProvider_test.go | 15 +++++++++++++-- .../autopilotevents/ready_servers_events.go | 9 +++++---- .../services/connectca/mock_ACLResolver.go | 13 ++++++++++++- .../services/connectca/mock_CAManager.go | 13 ++++++++++++- agent/grpc/public/services/connectca/server.go | 4 ++-- .../services/dataplane/mock_ACLResolver.go | 14 ++++++++++++-- agent/grpc/public/services/dataplane/server.go | 2 +- 17 files changed, 144 insertions(+), 27 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 3e5fca77aa..8241c652a7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -5,7 +5,7 @@ SHELL = bash GOTOOLS = \ github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs@master \ github.com/hashicorp/go-bindata/go-bindata@master \ - github.com/vektra/mockery/cmd/mockery@master \ + github.com/vektra/mockery/v2@latest \ github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2 \ github.com/hashicorp/lint-consul-retry@master diff --git a/agent/cache-types/mock_RPC.go b/agent/cache-types/mock_RPC.go index 6f642c66b8..67052f3549 100644 --- a/agent/cache-types/mock_RPC.go +++ b/agent/cache-types/mock_RPC.go @@ -1,7 +1,12 @@ -// Code generated by mockery v1.0.0 +// Code generated by mockery v2.11.0. DO NOT EDIT. + package cachetype -import mock "github.com/stretchr/testify/mock" +import ( + testing "testing" + + mock "github.com/stretchr/testify/mock" +) // MockRPC is an autogenerated mock type for the RPC type type MockRPC struct { @@ -21,3 +26,12 @@ func (_m *MockRPC) RPC(method string, args interface{}, reply interface{}) error return r0 } + +// NewMockRPC creates a new instance of MockRPC. It also registers a cleanup function to assert the mocks expectations. +func NewMockRPC(t testing.TB) *MockRPC { + mock := &MockRPC{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/cache-types/rpc.go b/agent/cache-types/rpc.go index 0aaf040f3d..ebf0925aff 100644 --- a/agent/cache-types/rpc.go +++ b/agent/cache-types/rpc.go @@ -1,6 +1,6 @@ package cachetype -//go:generate mockery -all -inpkg +//go:generate mockery --all --inpackage // RPC is an interface that an RPC client must implement. This is a helper // interface that is implemented by the agent delegate so that Type diff --git a/agent/cache/cache.go b/agent/cache/cache.go index e012b68683..f06ce27b24 100644 --- a/agent/cache/cache.go +++ b/agent/cache/cache.go @@ -33,7 +33,7 @@ import ( "github.com/hashicorp/consul/lib/ttlcache" ) -//go:generate mockery -all -inpkg +//go:generate mockery --all --inpackage // TODO(kit): remove the namespace from these once the metrics themselves change var Gauges = []prometheus.GaugeDefinition{ diff --git a/agent/cache/mock_Request.go b/agent/cache/mock_Request.go index c5af589241..7cd7343f8f 100644 --- a/agent/cache/mock_Request.go +++ b/agent/cache/mock_Request.go @@ -1,8 +1,12 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package cache -import mock "github.com/stretchr/testify/mock" +import ( + testing "testing" + + mock "github.com/stretchr/testify/mock" +) // MockRequest is an autogenerated mock type for the Request type type MockRequest struct { @@ -22,3 +26,12 @@ func (_m *MockRequest) CacheInfo() RequestInfo { return r0 } + +// NewMockRequest creates a new instance of MockRequest. It also registers a cleanup function to assert the mocks expectations. +func NewMockRequest(t testing.TB) *MockRequest { + mock := &MockRequest{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/cache/mock_Type.go b/agent/cache/mock_Type.go index 7c39fca329..628e7a0184 100644 --- a/agent/cache/mock_Type.go +++ b/agent/cache/mock_Type.go @@ -1,8 +1,12 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package cache -import mock "github.com/stretchr/testify/mock" +import ( + testing "testing" + + mock "github.com/stretchr/testify/mock" +) // MockType is an autogenerated mock type for the Type type type MockType struct { @@ -43,3 +47,12 @@ func (_m *MockType) RegisterOptions() RegisterOptions { return r0 } + +// NewMockType creates a new instance of MockType. It also registers a cleanup function to assert the mocks expectations. +func NewMockType(t testing.TB) *MockType { + mock := &MockType{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/connect/ca/mock_Provider.go b/agent/connect/ca/mock_Provider.go index ec79ea5c70..bdc5d9c8e6 100644 --- a/agent/connect/ca/mock_Provider.go +++ b/agent/connect/ca/mock_Provider.go @@ -1,11 +1,13 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package ca import ( - x509 "crypto/x509" + testing "testing" mock "github.com/stretchr/testify/mock" + + x509 "crypto/x509" ) // MockProvider is an autogenerated mock type for the Provider type @@ -245,3 +247,12 @@ func (_m *MockProvider) SupportsCrossSigning() (bool, error) { return r0, r1 } + +// NewMockProvider creates a new instance of MockProvider. It also registers a cleanup function to assert the mocks expectations. +func NewMockProvider(t testing.TB) *MockProvider { + mock := &MockProvider{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/connect/ca/provider.go b/agent/connect/ca/provider.go index 439c848ebb..0f6e6e14b1 100644 --- a/agent/connect/ca/provider.go +++ b/agent/connect/ca/provider.go @@ -5,7 +5,7 @@ import ( "errors" ) -//go:generate mockery -name Provider -inpkg +//go:generate mockery --name Provider --inpackage // ErrRateLimited is a sentinel error value Providers may return from any method // to indicate that the operation can't complete due to a temporary rate limit. diff --git a/agent/consul/autopilotevents/mock_Publisher_test.go b/agent/consul/autopilotevents/mock_Publisher_test.go index 45eefcce54..98f6e4065c 100644 --- a/agent/consul/autopilotevents/mock_Publisher_test.go +++ b/agent/consul/autopilotevents/mock_Publisher_test.go @@ -1,8 +1,10 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package autopilotevents import ( + testing "testing" + stream "github.com/hashicorp/consul/agent/consul/stream" mock "github.com/stretchr/testify/mock" ) @@ -16,3 +18,12 @@ type MockPublisher struct { func (_m *MockPublisher) Publish(_a0 []stream.Event) { _m.Called(_a0) } + +// NewMockPublisher creates a new instance of MockPublisher. It also registers a cleanup function to assert the mocks expectations. +func NewMockPublisher(t testing.TB) *MockPublisher { + mock := &MockPublisher{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/consul/autopilotevents/mock_StateStore_test.go b/agent/consul/autopilotevents/mock_StateStore_test.go index 3683e3ad96..7c8ee90031 100644 --- a/agent/consul/autopilotevents/mock_StateStore_test.go +++ b/agent/consul/autopilotevents/mock_StateStore_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package autopilotevents @@ -8,6 +8,8 @@ import ( structs "github.com/hashicorp/consul/agent/structs" + testing "testing" + types "github.com/hashicorp/consul/types" ) @@ -45,3 +47,12 @@ func (_m *MockStateStore) GetNodeID(_a0 types.NodeID, _a1 *acl.EnterpriseMeta) ( return r0, r1, r2 } + +// NewMockStateStore creates a new instance of MockStateStore. It also registers a cleanup function to assert the mocks expectations. +func NewMockStateStore(t testing.TB) *MockStateStore { + mock := &MockStateStore{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/consul/autopilotevents/mock_timeProvider_test.go b/agent/consul/autopilotevents/mock_timeProvider_test.go index fcc49e388f..147424101d 100644 --- a/agent/consul/autopilotevents/mock_timeProvider_test.go +++ b/agent/consul/autopilotevents/mock_timeProvider_test.go @@ -1,11 +1,13 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package autopilotevents import ( - time "time" + testing "testing" mock "github.com/stretchr/testify/mock" + + time "time" ) // mockTimeProvider is an autogenerated mock type for the timeProvider type @@ -26,3 +28,12 @@ func (_m *mockTimeProvider) Now() time.Time { return r0 } + +// newMockTimeProvider creates a new instance of mockTimeProvider. It also registers a cleanup function to assert the mocks expectations. +func newMockTimeProvider(t testing.TB) *mockTimeProvider { + mock := &mockTimeProvider{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/consul/autopilotevents/ready_servers_events.go b/agent/consul/autopilotevents/ready_servers_events.go index 5f39b7a175..dda14ebf93 100644 --- a/agent/consul/autopilotevents/ready_servers_events.go +++ b/agent/consul/autopilotevents/ready_servers_events.go @@ -7,11 +7,12 @@ import ( "sync" "time" + autopilot "github.com/hashicorp/raft-autopilot" + "github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/agent/consul/stream" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/types" - autopilot "github.com/hashicorp/raft-autopilot" ) const ( @@ -111,17 +112,17 @@ func NewReadyServersEventPublisher(config Config) *ReadyServersEventPublisher { } } -//go:generate mockery -name StateStore -inpkg -testonly +//go:generate mockery --name StateStore --inpackage --testonly type StateStore interface { GetNodeID(types.NodeID, *acl.EnterpriseMeta) (uint64, *structs.Node, error) } -//go:generate mockery -name Publisher -inpkg -testonly +//go:generate mockery --name Publisher --inpackage --testonly type Publisher interface { Publish([]stream.Event) } -//go:generate mockery -name timeProvider -inpkg -testonly +//go:generate mockery --name timeProvider --inpackage --testonly type timeProvider interface { Now() time.Time } diff --git a/agent/grpc/public/services/connectca/mock_ACLResolver.go b/agent/grpc/public/services/connectca/mock_ACLResolver.go index ce21ffdebd..a1ff427964 100644 --- a/agent/grpc/public/services/connectca/mock_ACLResolver.go +++ b/agent/grpc/public/services/connectca/mock_ACLResolver.go @@ -1,10 +1,12 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package connectca import ( acl "github.com/hashicorp/consul/acl" mock "github.com/stretchr/testify/mock" + + testing "testing" ) // MockACLResolver is an autogenerated mock type for the ACLResolver type @@ -34,3 +36,12 @@ func (_m *MockACLResolver) ResolveTokenAndDefaultMeta(token string, entMeta *acl return r0, r1 } + +// NewMockACLResolver creates a new instance of MockACLResolver. It also registers a cleanup function to assert the mocks expectations. +func NewMockACLResolver(t testing.TB) *MockACLResolver { + mock := &MockACLResolver{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/grpc/public/services/connectca/mock_CAManager.go b/agent/grpc/public/services/connectca/mock_CAManager.go index 1034c4b97d..8839344a2d 100644 --- a/agent/grpc/public/services/connectca/mock_CAManager.go +++ b/agent/grpc/public/services/connectca/mock_CAManager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package connectca @@ -8,6 +8,8 @@ import ( structs "github.com/hashicorp/consul/agent/structs" + testing "testing" + x509 "crypto/x509" ) @@ -38,3 +40,12 @@ func (_m *MockCAManager) AuthorizeAndSignCertificate(csr *x509.CertificateReques return r0, r1 } + +// NewMockCAManager creates a new instance of MockCAManager. It also registers a cleanup function to assert the mocks expectations. +func NewMockCAManager(t testing.TB) *MockCAManager { + mock := &MockCAManager{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/grpc/public/services/connectca/server.go b/agent/grpc/public/services/connectca/server.go index 1407e42d61..f9abd49ee4 100644 --- a/agent/grpc/public/services/connectca/server.go +++ b/agent/grpc/public/services/connectca/server.go @@ -39,12 +39,12 @@ type StateStore interface { AbandonCh() <-chan struct{} } -//go:generate mockery -name ACLResolver -inpkg +//go:generate mockery --name ACLResolver --inpackage type ACLResolver interface { ResolveTokenAndDefaultMeta(token string, entMeta *acl.EnterpriseMeta, authzContext *acl.AuthorizerContext) (acl.Authorizer, error) } -//go:generate mockery -name CAManager -inpkg +//go:generate mockery --name CAManager --inpackage type CAManager interface { AuthorizeAndSignCertificate(csr *x509.CertificateRequest, authz acl.Authorizer) (*structs.IssuedCert, error) } diff --git a/agent/grpc/public/services/dataplane/mock_ACLResolver.go b/agent/grpc/public/services/dataplane/mock_ACLResolver.go index 39d4b54770..1a73abfc81 100644 --- a/agent/grpc/public/services/dataplane/mock_ACLResolver.go +++ b/agent/grpc/public/services/dataplane/mock_ACLResolver.go @@ -1,11 +1,12 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package dataplane import ( + acl "github.com/hashicorp/consul/acl" mock "github.com/stretchr/testify/mock" - acl "github.com/hashicorp/consul/acl" + testing "testing" ) // MockACLResolver is an autogenerated mock type for the ACLResolver type @@ -35,3 +36,12 @@ func (_m *MockACLResolver) ResolveTokenAndDefaultMeta(_a0 string, _a1 *acl.Enter return r0, r1 } + +// NewMockACLResolver creates a new instance of MockACLResolver. It also registers a cleanup function to assert the mocks expectations. +func NewMockACLResolver(t testing.TB) *MockACLResolver { + mock := &MockACLResolver{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/agent/grpc/public/services/dataplane/server.go b/agent/grpc/public/services/dataplane/server.go index 3419b2d26e..80b0ccfafc 100644 --- a/agent/grpc/public/services/dataplane/server.go +++ b/agent/grpc/public/services/dataplane/server.go @@ -26,7 +26,7 @@ type StateStore interface { ServiceNode(string, string, string, *acl.EnterpriseMeta) (uint64, *structs.ServiceNode, error) } -//go:generate mockery -name ACLResolver -inpkg +//go:generate mockery --name ACLResolver --inpackage type ACLResolver interface { ResolveTokenAndDefaultMeta(string, *acl.EnterpriseMeta, *acl.AuthorizerContext) (acl.Authorizer, error) }