diff --git a/hack/make/prerequisites.mk b/hack/make/prerequisites.mk index 6622522a12..330dcd8547 100644 --- a/hack/make/prerequisites.mk +++ b/hack/make/prerequisites.mk @@ -9,7 +9,7 @@ gci_version=v0.13.5 # renovate depName=golang.org/x/tools golang_tools_version=v0.29.0 # renovate depName=github.com/vektra/mockery -mockery_version=v2.50.3 +mockery_version=v2.50.4 # renovate depName=github.com/igorshubovych/markdownlint-cli markdownlint_cli_version=v0.43.0 # renovate depName=github.com/helm-unittest/helm-unittest diff --git a/pkg/controllers/csi/provisioner/controller_test.go b/pkg/controllers/csi/provisioner/controller_test.go index 5ef4034869..0e03aa74f7 100644 --- a/pkg/controllers/csi/provisioner/controller_test.go +++ b/pkg/controllers/csi/provisioner/controller_test.go @@ -61,7 +61,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { dynakubeName := "test-dk" t.Run("no dynakube instance", func(t *testing.T) { - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) provisioner := &OneAgentProvisioner{ apiReader: fake.NewClient(), db: metadata.FakeMemoryDB(), @@ -74,7 +74,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { require.Equal(t, reconcile.Result{}, result) }) t.Run("dynakube deleted", func(t *testing.T) { - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) db := metadata.FakeMemoryDB() metadataDk := metadata.Dynakube{TenantUUID: tenantUUID, LatestVersion: agentVersion, Name: dkName} _ = db.InsertDynakube(ctx, &metadataDk) @@ -94,7 +94,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { require.Nil(t, ten) }) t.Run("csi driver not used (classicFullstack)", func(t *testing.T) { - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) provisioner := &OneAgentProvisioner{ apiReader: fake.NewClient( &dynakube.DynaKube{ @@ -143,7 +143,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { ) mockDtcBuilder := dtbuildermock.NewBuilder(t) - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) db := metadata.FakeMemoryDB() provisioner := &OneAgentProvisioner{ @@ -166,7 +166,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { require.Len(t, dynakubeMetadatas, 1) }) t.Run("no tokens", func(t *testing.T) { - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) provisioner := &OneAgentProvisioner{ apiReader: fake.NewClient( addFakeTenantUUID( @@ -200,7 +200,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { require.NotNil(t, result) }) t.Run("error when creating dynatrace client", func(t *testing.T) { - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) mockDtcBuilder := dtbuildermock.NewBuilder(t) mockDtcBuilder.On("SetContext", mock.Anything).Return(mockDtcBuilder) mockDtcBuilder.On("SetDynakube", mock.Anything).Return(mockDtcBuilder) @@ -249,7 +249,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { require.NotNil(t, result) }) t.Run("error creating directories", func(t *testing.T) { - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) errorfs := &mkDirAllErrorFs{ Fs: afero.NewMemMapFs(), } @@ -293,7 +293,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { log.Info("") }) t.Run("error getting latest agent version", func(t *testing.T) { - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) memFs := afero.NewMemMapFs() mockDtcBuilder := dtbuildermock.NewBuilder(t) dynakube := addFakeTenantUUID( @@ -354,7 +354,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { require.True(t, exists) }) t.Run("error getting dynakube from db", func(t *testing.T) { - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) memFs := afero.NewMemMapFs() mockDtcBuilder := dtbuildermock.NewBuilder(t) @@ -396,7 +396,7 @@ func TestOneAgentProvisioner_Reconcile(t *testing.T) { require.Empty(t, result) }) t.Run("correct directories are created", func(t *testing.T) { - gc := reconcilermock.NewReconciler(t) + gc := reconcilermock.NewReconciler[reconcile.Request](t) memFs := afero.NewMemMapFs() memDB := metadata.FakeMemoryDB() dynakube := addFakeTenantUUID( diff --git a/test/mocks/sigs.k8s.io/controller-runtime/pkg/reconcile/reconciler.go b/test/mocks/sigs.k8s.io/controller-runtime/pkg/reconcile/reconciler.go index 35e031341c..1d39ff638d 100644 --- a/test/mocks/sigs.k8s.io/controller-runtime/pkg/reconcile/reconciler.go +++ b/test/mocks/sigs.k8s.io/controller-runtime/pkg/reconcile/reconciler.go @@ -10,20 +10,20 @@ import ( ) // Reconciler is an autogenerated mock type for the Reconciler type -type Reconciler struct { +type Reconciler[request comparable] struct { mock.Mock } -type Reconciler_Expecter struct { +type Reconciler_Expecter[request comparable] struct { mock *mock.Mock } -func (_m *Reconciler) EXPECT() *Reconciler_Expecter { - return &Reconciler_Expecter{mock: &_m.Mock} +func (_m *Reconciler[request]) EXPECT() *Reconciler_Expecter[request] { + return &Reconciler_Expecter[request]{mock: &_m.Mock} } // Reconcile provides a mock function with given fields: _a0, _a1 -func (_m *Reconciler) Reconcile(_a0 context.Context, _a1 reconcile.Request) (reconcile.Result, error) { +func (_m *Reconciler[request]) Reconcile(_a0 context.Context, _a1 reconcile.Request) (reconcile.Result, error) { ret := _m.Called(_a0, _a1) if len(ret) == 0 { @@ -51,41 +51,41 @@ func (_m *Reconciler) Reconcile(_a0 context.Context, _a1 reconcile.Request) (rec } // Reconciler_Reconcile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Reconcile' -type Reconciler_Reconcile_Call struct { +type Reconciler_Reconcile_Call[request comparable] struct { *mock.Call } // Reconcile is a helper method to define mock.On call // - _a0 context.Context // - _a1 reconcile.Request -func (_e *Reconciler_Expecter) Reconcile(_a0 interface{}, _a1 interface{}) *Reconciler_Reconcile_Call { - return &Reconciler_Reconcile_Call{Call: _e.mock.On("Reconcile", _a0, _a1)} +func (_e *Reconciler_Expecter[request]) Reconcile(_a0 interface{}, _a1 interface{}) *Reconciler_Reconcile_Call[request] { + return &Reconciler_Reconcile_Call[request]{Call: _e.mock.On("Reconcile", _a0, _a1)} } -func (_c *Reconciler_Reconcile_Call) Run(run func(_a0 context.Context, _a1 reconcile.Request)) *Reconciler_Reconcile_Call { +func (_c *Reconciler_Reconcile_Call[request]) Run(run func(_a0 context.Context, _a1 reconcile.Request)) *Reconciler_Reconcile_Call[request] { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(reconcile.Request)) }) return _c } -func (_c *Reconciler_Reconcile_Call) Return(_a0 reconcile.Result, _a1 error) *Reconciler_Reconcile_Call { +func (_c *Reconciler_Reconcile_Call[request]) Return(_a0 reconcile.Result, _a1 error) *Reconciler_Reconcile_Call[request] { _c.Call.Return(_a0, _a1) return _c } -func (_c *Reconciler_Reconcile_Call) RunAndReturn(run func(context.Context, reconcile.Request) (reconcile.Result, error)) *Reconciler_Reconcile_Call { +func (_c *Reconciler_Reconcile_Call[request]) RunAndReturn(run func(context.Context, reconcile.Request) (reconcile.Result, error)) *Reconciler_Reconcile_Call[request] { _c.Call.Return(run) return _c } // NewReconciler creates a new instance of Reconciler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. -func NewReconciler(t interface { +func NewReconciler[request comparable](t interface { mock.TestingT Cleanup(func()) -}) *Reconciler { - mock := &Reconciler{} +}) *Reconciler[request] { + mock := &Reconciler[request]{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) })