From 964b2b183f2144e5d0a66e611e4daacd9c985b73 Mon Sep 17 00:00:00 2001 From: Rafal Foks Date: Wed, 28 Aug 2024 09:07:46 +0200 Subject: [PATCH] Add mocks --- internal/auditlogging/mocks/AuditLogging.go | 57 +++++++ .../mocks/auditLogConfigurator.go | 146 ++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 internal/auditlogging/mocks/AuditLogging.go create mode 100644 internal/auditlogging/mocks/auditLogConfigurator.go diff --git a/internal/auditlogging/mocks/AuditLogging.go b/internal/auditlogging/mocks/AuditLogging.go new file mode 100644 index 00000000..f670fd14 --- /dev/null +++ b/internal/auditlogging/mocks/AuditLogging.go @@ -0,0 +1,57 @@ +// Code generated by mockery v2.44.2. DO NOT EDIT. + +package mocks + +import ( + context "context" + + v1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1" + mock "github.com/stretchr/testify/mock" +) + +// AuditLogging is an autogenerated mock type for the AuditLogging type +type AuditLogging struct { + mock.Mock +} + +// Enable provides a mock function with given fields: ctx, shoot +func (_m *AuditLogging) Enable(ctx context.Context, shoot *v1beta1.Shoot) (bool, error) { + ret := _m.Called(ctx, shoot) + + if len(ret) == 0 { + panic("no return value specified for Enable") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta1.Shoot) (bool, error)); ok { + return rf(ctx, shoot) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta1.Shoot) bool); ok { + r0 = rf(ctx, shoot) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta1.Shoot) error); ok { + r1 = rf(ctx, shoot) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewAuditLogging creates a new instance of AuditLogging. 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 NewAuditLogging(t interface { + mock.TestingT + Cleanup(func()) +}) *AuditLogging { + mock := &AuditLogging{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/auditlogging/mocks/auditLogConfigurator.go b/internal/auditlogging/mocks/auditLogConfigurator.go new file mode 100644 index 00000000..ab57bca6 --- /dev/null +++ b/internal/auditlogging/mocks/auditLogConfigurator.go @@ -0,0 +1,146 @@ +// Code generated by mockery v2.44.2. DO NOT EDIT. + +package mocks + +import ( + context "context" + + auditlogging "github.com/kyma-project/infrastructure-manager/internal/auditlogging" + + mock "github.com/stretchr/testify/mock" + + types "k8s.io/apimachinery/pkg/types" + + v1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1" +) + +// auditLogConfigurator is an autogenerated mock type for the auditLogConfigurator type +type auditLogConfigurator struct { + mock.Mock +} + +// canEnableAuditLogsForShoot provides a mock function with given fields: seedName +func (_m *auditLogConfigurator) canEnableAuditLogsForShoot(seedName string) bool { + ret := _m.Called(seedName) + + if len(ret) == 0 { + panic("no return value specified for canEnableAuditLogsForShoot") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(string) bool); ok { + r0 = rf(seedName) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// getConfigFromFile provides a mock function with given fields: +func (_m *auditLogConfigurator) getConfigFromFile() (map[string]map[string]auditlogging.AuditLogData, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for getConfigFromFile") + } + + var r0 map[string]map[string]auditlogging.AuditLogData + var r1 error + if rf, ok := ret.Get(0).(func() (map[string]map[string]auditlogging.AuditLogData, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() map[string]map[string]auditlogging.AuditLogData); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]map[string]auditlogging.AuditLogData) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// getPolicyConfigMapName provides a mock function with given fields: +func (_m *auditLogConfigurator) getPolicyConfigMapName() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for getPolicyConfigMapName") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// getSeedObj provides a mock function with given fields: ctx, seedKey +func (_m *auditLogConfigurator) getSeedObj(ctx context.Context, seedKey types.NamespacedName) (v1beta1.Seed, error) { + ret := _m.Called(ctx, seedKey) + + if len(ret) == 0 { + panic("no return value specified for getSeedObj") + } + + var r0 v1beta1.Seed + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.NamespacedName) (v1beta1.Seed, error)); ok { + return rf(ctx, seedKey) + } + if rf, ok := ret.Get(0).(func(context.Context, types.NamespacedName) v1beta1.Seed); ok { + r0 = rf(ctx, seedKey) + } else { + r0 = ret.Get(0).(v1beta1.Seed) + } + + if rf, ok := ret.Get(1).(func(context.Context, types.NamespacedName) error); ok { + r1 = rf(ctx, seedKey) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// getTenantConfigPath provides a mock function with given fields: +func (_m *auditLogConfigurator) getTenantConfigPath() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for getTenantConfigPath") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// newAuditLogConfigurator creates a new instance of auditLogConfigurator. 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 newAuditLogConfigurator(t interface { + mock.TestingT + Cleanup(func()) +}) *auditLogConfigurator { + mock := &auditLogConfigurator{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}