From cec566bb615045f2d10c084ae033a7b141a6626e Mon Sep 17 00:00:00 2001 From: Andre Sterba <andre.sterba@stud.h-da.de> Date: Thu, 14 Jul 2022 07:09:36 +0000 Subject: [PATCH] Add mock generation to Makefile and update mocks See merge request danet/gosdn!350 --- controller/Makefile | 4 + controller/mocks/Change.go | 16 ++- controller/mocks/Device.go | 35 +++++- controller/mocks/NetworkDomain.go | 14 ++- controller/mocks/Plugin.go | 17 +-- controller/mocks/PndStore.go | 148 ++++++++++++++++++++++++ controller/mocks/Role.go | 94 +++++++++++++++ controller/mocks/RoleService.go | 117 +++++++++++++++++++ controller/mocks/RoleStore.go | 115 ++++++++++++++++++ controller/mocks/Service.go | 118 +++++++++++++++++++ controller/mocks/SouthboundInterface.go | 14 ++- controller/mocks/Storable.go | 14 ++- controller/mocks/Store.go | 110 ++++++++++++++++++ controller/mocks/Transport.go | 14 ++- controller/mocks/User.go | 122 +++++++++++++++++++ controller/mocks/UserService.go | 117 +++++++++++++++++++ controller/mocks/UserStore.go | 115 ++++++++++++++++++ 17 files changed, 1146 insertions(+), 38 deletions(-) create mode 100644 controller/mocks/PndStore.go create mode 100644 controller/mocks/Role.go create mode 100644 controller/mocks/RoleService.go create mode 100644 controller/mocks/RoleStore.go create mode 100644 controller/mocks/Service.go create mode 100644 controller/mocks/Store.go create mode 100644 controller/mocks/User.go create mode 100644 controller/mocks/UserService.go create mode 100644 controller/mocks/UserStore.go diff --git a/controller/Makefile b/controller/Makefile index 172b33e0d..be2919c1e 100644 --- a/controller/Makefile +++ b/controller/Makefile @@ -16,6 +16,7 @@ install-tools: mkdir -p $(GOSDN_PRG) go install gotest.tools/gotestsum@v1.7.0 go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.1 + go install github.com/vektra/mockery/v2@v2.14.0 @echo Finished installing development tooling ci-install-tools: @@ -59,3 +60,6 @@ integration-test-api: ENVIRONMENT=testing &&\ cd ./api &&\ go test -race -v -run TestApiIntegration + +generate-mocks: install-tools + ./$(TOOLS_DIR)/mockery --all --dir "./interfaces/" diff --git a/controller/mocks/Change.go b/controller/mocks/Change.go index fb370384e..44907e267 100644 --- a/controller/mocks/Change.go +++ b/controller/mocks/Change.go @@ -1,15 +1,13 @@ -// Code generated by mockery v2.11.0. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package mocks import ( - testing "testing" + time "time" pnd "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" mock "github.com/stretchr/testify/mock" - time "time" - uuid "github.com/google/uuid" ygot "github.com/openconfig/ygot/ygot" @@ -124,9 +122,15 @@ func (_m *Change) State() pnd.ChangeState { return r0 } -// NewChange creates a new instance of Change. It also registers a cleanup function to assert the mocks expectations. -func NewChange(t testing.TB) *Change { +type mockConstructorTestingTNewChange interface { + mock.TestingT + Cleanup(func()) +} + +// NewChange creates a new instance of Change. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewChange(t mockConstructorTestingTNewChange) *Change { mock := &Change{} + mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/controller/mocks/Device.go b/controller/mocks/Device.go index 3ac588a2c..5cac8a61d 100644 --- a/controller/mocks/Device.go +++ b/controller/mocks/Device.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.11.0. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package mocks @@ -7,8 +7,6 @@ import ( mock "github.com/stretchr/testify/mock" protoreflect "google.golang.org/protobuf/reflect/protoreflect" - testing "testing" - transport "code.fbi.h-da.de/danet/gosdn/controller/interfaces/transport" uuid "github.com/google/uuid" @@ -60,6 +58,27 @@ func (_m *Device) GetModel() ygot.GoStruct { return r0 } +// GetModelAsString provides a mock function with given fields: +func (_m *Device) GetModelAsString() (string, error) { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // ID provides a mock function with given fields: func (_m *Device) ID() uuid.UUID { ret := _m.Called() @@ -150,9 +169,15 @@ func (_m *Device) Transport() transport.Transport { return r0 } -// NewDevice creates a new instance of Device. It also registers a cleanup function to assert the mocks expectations. -func NewDevice(t testing.TB) *Device { +type mockConstructorTestingTNewDevice interface { + mock.TestingT + Cleanup(func()) +} + +// NewDevice creates a new instance of Device. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewDevice(t mockConstructorTestingTNewDevice) *Device { mock := &Device{} + mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/controller/mocks/NetworkDomain.go b/controller/mocks/NetworkDomain.go index 22e6e7bfc..746eafaf7 100644 --- a/controller/mocks/NetworkDomain.go +++ b/controller/mocks/NetworkDomain.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.11.0. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package mocks @@ -14,8 +14,6 @@ import ( southbound "code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound" - testing "testing" - transport "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport" uuid "github.com/google/uuid" @@ -405,9 +403,15 @@ func (_m *NetworkDomain) RequestAll(_a0 string) error { return r0 } -// NewNetworkDomain creates a new instance of NetworkDomain. It also registers a cleanup function to assert the mocks expectations. -func NewNetworkDomain(t testing.TB) *NetworkDomain { +type mockConstructorTestingTNewNetworkDomain interface { + mock.TestingT + Cleanup(func()) +} + +// NewNetworkDomain creates a new instance of NetworkDomain. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewNetworkDomain(t mockConstructorTestingTNewNetworkDomain) *NetworkDomain { mock := &NetworkDomain{} + mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/controller/mocks/Plugin.go b/controller/mocks/Plugin.go index b6d86b916..db904b743 100644 --- a/controller/mocks/Plugin.go +++ b/controller/mocks/Plugin.go @@ -1,14 +1,11 @@ -// Code generated by mockery v2.11.0. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package mocks import ( - testing "testing" - plugin "code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin" - mock "github.com/stretchr/testify/mock" - uuid "github.com/google/uuid" + mock "github.com/stretchr/testify/mock" ) // Plugin is an autogenerated mock type for the Plugin type @@ -90,9 +87,15 @@ func (_m *Plugin) Update() error { return r0 } -// NewPlugin creates a new instance of Plugin. It also registers a cleanup function to assert the mocks expectations. -func NewPlugin(t testing.TB) *Plugin { +type mockConstructorTestingTNewPlugin interface { + mock.TestingT + Cleanup(func()) +} + +// NewPlugin creates a new instance of Plugin. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewPlugin(t mockConstructorTestingTNewPlugin) *Plugin { mock := &Plugin{} + mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/controller/mocks/PndStore.go b/controller/mocks/PndStore.go new file mode 100644 index 000000000..9081553ca --- /dev/null +++ b/controller/mocks/PndStore.go @@ -0,0 +1,148 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + device "code.fbi.h-da.de/danet/gosdn/controller/interfaces/device" + mock "github.com/stretchr/testify/mock" + + networkdomain "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain" + + store "code.fbi.h-da.de/danet/gosdn/controller/store" + + uuid "github.com/google/uuid" +) + +// PndStore is an autogenerated mock type for the PndStore type +type PndStore struct { + mock.Mock +} + +// Add provides a mock function with given fields: _a0 +func (_m *PndStore) Add(_a0 networkdomain.NetworkDomain) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(networkdomain.NetworkDomain) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// AddPendingChannel provides a mock function with given fields: id, ch +func (_m *PndStore) AddPendingChannel(id uuid.UUID, ch chan device.Details) { + _m.Called(id, ch) +} + +// Delete provides a mock function with given fields: _a0 +func (_m *PndStore) Delete(_a0 networkdomain.NetworkDomain) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(networkdomain.NetworkDomain) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Get provides a mock function with given fields: _a0 +func (_m *PndStore) Get(_a0 store.Query) (networkdomain.NetworkDomain, error) { + ret := _m.Called(_a0) + + var r0 networkdomain.NetworkDomain + if rf, ok := ret.Get(0).(func(store.Query) networkdomain.NetworkDomain); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(networkdomain.NetworkDomain) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(store.Query) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetAll provides a mock function with given fields: +func (_m *PndStore) GetAll() ([]networkdomain.NetworkDomain, error) { + ret := _m.Called() + + var r0 []networkdomain.NetworkDomain + if rf, ok := ret.Get(0).(func() []networkdomain.NetworkDomain); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]networkdomain.NetworkDomain) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// PendingChannels provides a mock function with given fields: id, parseErrors +func (_m *PndStore) PendingChannels(id uuid.UUID, parseErrors ...error) (chan device.Details, error) { + _va := make([]interface{}, len(parseErrors)) + for _i := range parseErrors { + _va[_i] = parseErrors[_i] + } + var _ca []interface{} + _ca = append(_ca, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 chan device.Details + if rf, ok := ret.Get(0).(func(uuid.UUID, ...error) chan device.Details); ok { + r0 = rf(id, parseErrors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(chan device.Details) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(uuid.UUID, ...error) error); ok { + r1 = rf(id, parseErrors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RemovePendingChannel provides a mock function with given fields: id +func (_m *PndStore) RemovePendingChannel(id uuid.UUID) { + _m.Called(id) +} + +type mockConstructorTestingTNewPndStore interface { + mock.TestingT + Cleanup(func()) +} + +// NewPndStore creates a new instance of PndStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewPndStore(t mockConstructorTestingTNewPndStore) *PndStore { + mock := &PndStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/Role.go b/controller/mocks/Role.go new file mode 100644 index 000000000..1505dd636 --- /dev/null +++ b/controller/mocks/Role.go @@ -0,0 +1,94 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + + uuid "github.com/google/uuid" +) + +// Role is an autogenerated mock type for the Role type +type Role struct { + mock.Mock +} + +// GetDescription provides a mock function with given fields: +func (_m *Role) GetDescription() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// GetPermissions provides a mock function with given fields: +func (_m *Role) GetPermissions() []string { + ret := _m.Called() + + var r0 []string + if rf, ok := ret.Get(0).(func() []string); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + return r0 +} + +// ID provides a mock function with given fields: +func (_m *Role) ID() uuid.UUID { + ret := _m.Called() + + var r0 uuid.UUID + if rf, ok := ret.Get(0).(func() uuid.UUID); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(uuid.UUID) + } + } + + return r0 +} + +// Name provides a mock function with given fields: +func (_m *Role) Name() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// RemovePermissionsFromRole provides a mock function with given fields: _a0 +func (_m *Role) RemovePermissionsFromRole(_a0 []string) { + _m.Called(_a0) +} + +type mockConstructorTestingTNewRole interface { + mock.TestingT + Cleanup(func()) +} + +// NewRole creates a new instance of Role. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewRole(t mockConstructorTestingTNewRole) *Role { + mock := &Role{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/RoleService.go b/controller/mocks/RoleService.go new file mode 100644 index 000000000..b4bcd18f1 --- /dev/null +++ b/controller/mocks/RoleService.go @@ -0,0 +1,117 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + rbac "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" + store "code.fbi.h-da.de/danet/gosdn/controller/store" + mock "github.com/stretchr/testify/mock" +) + +// RoleService is an autogenerated mock type for the RoleService type +type RoleService struct { + mock.Mock +} + +// Add provides a mock function with given fields: _a0 +func (_m *RoleService) Add(_a0 rbac.Role) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Delete provides a mock function with given fields: _a0 +func (_m *RoleService) Delete(_a0 rbac.Role) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Get provides a mock function with given fields: _a0 +func (_m *RoleService) Get(_a0 store.Query) (rbac.Role, error) { + ret := _m.Called(_a0) + + var r0 rbac.Role + if rf, ok := ret.Get(0).(func(store.Query) rbac.Role); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(rbac.Role) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(store.Query) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetAll provides a mock function with given fields: +func (_m *RoleService) GetAll() ([]rbac.Role, error) { + ret := _m.Called() + + var r0 []rbac.Role + if rf, ok := ret.Get(0).(func() []rbac.Role); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]rbac.Role) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Update provides a mock function with given fields: _a0 +func (_m *RoleService) Update(_a0 rbac.Role) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type mockConstructorTestingTNewRoleService interface { + mock.TestingT + Cleanup(func()) +} + +// NewRoleService creates a new instance of RoleService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewRoleService(t mockConstructorTestingTNewRoleService) *RoleService { + mock := &RoleService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/RoleStore.go b/controller/mocks/RoleStore.go new file mode 100644 index 000000000..4f1c38106 --- /dev/null +++ b/controller/mocks/RoleStore.go @@ -0,0 +1,115 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + rbac "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" + store "code.fbi.h-da.de/danet/gosdn/controller/store" + mock "github.com/stretchr/testify/mock" +) + +// RoleStore is an autogenerated mock type for the RoleStore type +type RoleStore struct { + mock.Mock +} + +// Add provides a mock function with given fields: r +func (_m *RoleStore) Add(r rbac.Role) error { + ret := _m.Called(r) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + r0 = rf(r) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Delete provides a mock function with given fields: _a0 +func (_m *RoleStore) Delete(_a0 rbac.Role) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Get provides a mock function with given fields: _a0 +func (_m *RoleStore) Get(_a0 store.Query) (rbac.LoadedRole, error) { + ret := _m.Called(_a0) + + var r0 rbac.LoadedRole + if rf, ok := ret.Get(0).(func(store.Query) rbac.LoadedRole); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(rbac.LoadedRole) + } + + var r1 error + if rf, ok := ret.Get(1).(func(store.Query) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetAll provides a mock function with given fields: +func (_m *RoleStore) GetAll() ([]rbac.LoadedRole, error) { + ret := _m.Called() + + var r0 []rbac.LoadedRole + if rf, ok := ret.Get(0).(func() []rbac.LoadedRole); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]rbac.LoadedRole) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Update provides a mock function with given fields: r +func (_m *RoleStore) Update(r rbac.Role) error { + ret := _m.Called(r) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + r0 = rf(r) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type mockConstructorTestingTNewRoleStore interface { + mock.TestingT + Cleanup(func()) +} + +// NewRoleStore creates a new instance of RoleStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewRoleStore(t mockConstructorTestingTNewRoleStore) *RoleStore { + mock := &RoleStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/Service.go b/controller/mocks/Service.go new file mode 100644 index 000000000..7d0768e06 --- /dev/null +++ b/controller/mocks/Service.go @@ -0,0 +1,118 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + device "code.fbi.h-da.de/danet/gosdn/controller/interfaces/device" + mock "github.com/stretchr/testify/mock" + + store "code.fbi.h-da.de/danet/gosdn/controller/store" +) + +// Service is an autogenerated mock type for the Service type +type Service struct { + mock.Mock +} + +// Add provides a mock function with given fields: _a0 +func (_m *Service) Add(_a0 device.Device) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(device.Device) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Delete provides a mock function with given fields: _a0 +func (_m *Service) Delete(_a0 device.Device) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(device.Device) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Get provides a mock function with given fields: _a0 +func (_m *Service) Get(_a0 store.Query) (device.Device, error) { + ret := _m.Called(_a0) + + var r0 device.Device + if rf, ok := ret.Get(0).(func(store.Query) device.Device); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(device.Device) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(store.Query) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetAll provides a mock function with given fields: +func (_m *Service) GetAll() ([]device.Device, error) { + ret := _m.Called() + + var r0 []device.Device + if rf, ok := ret.Get(0).(func() []device.Device); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]device.Device) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Update provides a mock function with given fields: _a0 +func (_m *Service) Update(_a0 device.Device) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(device.Device) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type mockConstructorTestingTNewService interface { + mock.TestingT + Cleanup(func()) +} + +// NewService creates a new instance of Service. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewService(t mockConstructorTestingTNewService) *Service { + mock := &Service{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/SouthboundInterface.go b/controller/mocks/SouthboundInterface.go index 2a6fcead3..f03602f4e 100644 --- a/controller/mocks/SouthboundInterface.go +++ b/controller/mocks/SouthboundInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.11.0. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package mocks @@ -7,8 +7,6 @@ import ( gnmi "github.com/openconfig/gnmi/proto/gnmi" mock "github.com/stretchr/testify/mock" - testing "testing" - uuid "github.com/google/uuid" yang "github.com/openconfig/goyang/pkg/yang" @@ -146,9 +144,15 @@ func (_m *SouthboundInterface) Unmarshal(_a0 []byte, _a1 *gnmi.Path, _a2 ygot.Go return r0 } -// NewSouthboundInterface creates a new instance of SouthboundInterface. It also registers a cleanup function to assert the mocks expectations. -func NewSouthboundInterface(t testing.TB) *SouthboundInterface { +type mockConstructorTestingTNewSouthboundInterface interface { + mock.TestingT + Cleanup(func()) +} + +// NewSouthboundInterface creates a new instance of SouthboundInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewSouthboundInterface(t mockConstructorTestingTNewSouthboundInterface) *SouthboundInterface { mock := &SouthboundInterface{} + mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/controller/mocks/Storable.go b/controller/mocks/Storable.go index 9219bcfc0..b6e90b8f1 100644 --- a/controller/mocks/Storable.go +++ b/controller/mocks/Storable.go @@ -1,12 +1,10 @@ -// Code generated by mockery v2.11.0. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package mocks import ( mock "github.com/stretchr/testify/mock" - testing "testing" - uuid "github.com/google/uuid" ) @@ -31,9 +29,15 @@ func (_m *Storable) ID() uuid.UUID { return r0 } -// NewStorable creates a new instance of Storable. It also registers a cleanup function to assert the mocks expectations. -func NewStorable(t testing.TB) *Storable { +type mockConstructorTestingTNewStorable interface { + mock.TestingT + Cleanup(func()) +} + +// NewStorable creates a new instance of Storable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewStorable(t mockConstructorTestingTNewStorable) *Storable { mock := &Storable{} + mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/controller/mocks/Store.go b/controller/mocks/Store.go new file mode 100644 index 000000000..6ce0fd985 --- /dev/null +++ b/controller/mocks/Store.go @@ -0,0 +1,110 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + store "code.fbi.h-da.de/danet/gosdn/controller/interfaces/store" + uuid "github.com/google/uuid" + mock "github.com/stretchr/testify/mock" +) + +// Store is an autogenerated mock type for the Store type +type Store struct { + mock.Mock +} + +// Add provides a mock function with given fields: item +func (_m *Store) Add(item store.Storable) error { + ret := _m.Called(item) + + var r0 error + if rf, ok := ret.Get(0).(func(store.Storable) error); ok { + r0 = rf(item) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Delete provides a mock function with given fields: id +func (_m *Store) Delete(id uuid.UUID) error { + ret := _m.Called(id) + + var r0 error + if rf, ok := ret.Get(0).(func(uuid.UUID) error); ok { + r0 = rf(id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Exists provides a mock function with given fields: id +func (_m *Store) Exists(id uuid.UUID) bool { + ret := _m.Called(id) + + var r0 bool + if rf, ok := ret.Get(0).(func(uuid.UUID) bool); ok { + r0 = rf(id) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// Get provides a mock function with given fields: id +func (_m *Store) Get(id uuid.UUID) (store.Storable, error) { + ret := _m.Called(id) + + var r0 store.Storable + if rf, ok := ret.Get(0).(func(uuid.UUID) store.Storable); ok { + r0 = rf(id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(store.Storable) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(uuid.UUID) error); ok { + r1 = rf(id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UUIDs provides a mock function with given fields: +func (_m *Store) UUIDs() []uuid.UUID { + ret := _m.Called() + + var r0 []uuid.UUID + if rf, ok := ret.Get(0).(func() []uuid.UUID); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uuid.UUID) + } + } + + return r0 +} + +type mockConstructorTestingTNewStore interface { + mock.TestingT + Cleanup(func()) +} + +// NewStore creates a new instance of Store. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewStore(t mockConstructorTestingTNewStore) *Store { + mock := &Store{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/Transport.go b/controller/mocks/Transport.go index 10fa882e3..fffcb59cf 100644 --- a/controller/mocks/Transport.go +++ b/controller/mocks/Transport.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.11.0. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package mocks @@ -9,8 +9,6 @@ import ( mock "github.com/stretchr/testify/mock" - testing "testing" - ytypes "github.com/openconfig/ygot/ytypes" ) @@ -112,9 +110,15 @@ func (_m *Transport) Type() string { return r0 } -// NewTransport creates a new instance of Transport. It also registers a cleanup function to assert the mocks expectations. -func NewTransport(t testing.TB) *Transport { +type mockConstructorTestingTNewTransport interface { + mock.TestingT + Cleanup(func()) +} + +// NewTransport creates a new instance of Transport. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewTransport(t mockConstructorTestingTNewTransport) *Transport { mock := &Transport{} + mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/controller/mocks/User.go b/controller/mocks/User.go new file mode 100644 index 000000000..27dd42bcc --- /dev/null +++ b/controller/mocks/User.go @@ -0,0 +1,122 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + + uuid "github.com/google/uuid" +) + +// User is an autogenerated mock type for the User type +type User struct { + mock.Mock +} + +// GetPassword provides a mock function with given fields: +func (_m *User) GetPassword() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// GetRoles provides a mock function with given fields: +func (_m *User) GetRoles() map[string]string { + ret := _m.Called() + + var r0 map[string]string + if rf, ok := ret.Get(0).(func() map[string]string); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]string) + } + } + + return r0 +} + +// GetSalt provides a mock function with given fields: +func (_m *User) GetSalt() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// GetToken provides a mock function with given fields: +func (_m *User) GetToken() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// ID provides a mock function with given fields: +func (_m *User) ID() uuid.UUID { + ret := _m.Called() + + var r0 uuid.UUID + if rf, ok := ret.Get(0).(func() uuid.UUID); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(uuid.UUID) + } + } + + return r0 +} + +// Name provides a mock function with given fields: +func (_m *User) Name() string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// SetToken provides a mock function with given fields: _a0 +func (_m *User) SetToken(_a0 string) { + _m.Called(_a0) +} + +type mockConstructorTestingTNewUser interface { + mock.TestingT + Cleanup(func()) +} + +// NewUser creates a new instance of User. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewUser(t mockConstructorTestingTNewUser) *User { + mock := &User{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/UserService.go b/controller/mocks/UserService.go new file mode 100644 index 000000000..ebcba089e --- /dev/null +++ b/controller/mocks/UserService.go @@ -0,0 +1,117 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + rbac "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" + store "code.fbi.h-da.de/danet/gosdn/controller/store" + mock "github.com/stretchr/testify/mock" +) + +// UserService is an autogenerated mock type for the UserService type +type UserService struct { + mock.Mock +} + +// Add provides a mock function with given fields: _a0 +func (_m *UserService) Add(_a0 rbac.User) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Delete provides a mock function with given fields: _a0 +func (_m *UserService) Delete(_a0 rbac.User) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Get provides a mock function with given fields: _a0 +func (_m *UserService) Get(_a0 store.Query) (rbac.User, error) { + ret := _m.Called(_a0) + + var r0 rbac.User + if rf, ok := ret.Get(0).(func(store.Query) rbac.User); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(rbac.User) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(store.Query) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetAll provides a mock function with given fields: +func (_m *UserService) GetAll() ([]rbac.User, error) { + ret := _m.Called() + + var r0 []rbac.User + if rf, ok := ret.Get(0).(func() []rbac.User); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]rbac.User) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Update provides a mock function with given fields: _a0 +func (_m *UserService) Update(_a0 rbac.User) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type mockConstructorTestingTNewUserService interface { + mock.TestingT + Cleanup(func()) +} + +// NewUserService creates a new instance of UserService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewUserService(t mockConstructorTestingTNewUserService) *UserService { + mock := &UserService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/UserStore.go b/controller/mocks/UserStore.go new file mode 100644 index 000000000..c679b9897 --- /dev/null +++ b/controller/mocks/UserStore.go @@ -0,0 +1,115 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + rbac "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" + store "code.fbi.h-da.de/danet/gosdn/controller/store" + mock "github.com/stretchr/testify/mock" +) + +// UserStore is an autogenerated mock type for the UserStore type +type UserStore struct { + mock.Mock +} + +// Add provides a mock function with given fields: u +func (_m *UserStore) Add(u rbac.User) error { + ret := _m.Called(u) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + r0 = rf(u) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Delete provides a mock function with given fields: _a0 +func (_m *UserStore) Delete(_a0 rbac.User) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Get provides a mock function with given fields: _a0 +func (_m *UserStore) Get(_a0 store.Query) (rbac.LoadedUser, error) { + ret := _m.Called(_a0) + + var r0 rbac.LoadedUser + if rf, ok := ret.Get(0).(func(store.Query) rbac.LoadedUser); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(rbac.LoadedUser) + } + + var r1 error + if rf, ok := ret.Get(1).(func(store.Query) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetAll provides a mock function with given fields: +func (_m *UserStore) GetAll() ([]rbac.LoadedUser, error) { + ret := _m.Called() + + var r0 []rbac.LoadedUser + if rf, ok := ret.Get(0).(func() []rbac.LoadedUser); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]rbac.LoadedUser) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Update provides a mock function with given fields: u +func (_m *UserStore) Update(u rbac.User) error { + ret := _m.Called(u) + + var r0 error + if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + r0 = rf(u) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type mockConstructorTestingTNewUserStore interface { + mock.TestingT + Cleanup(func()) +} + +// NewUserStore creates a new instance of UserStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewUserStore(t mockConstructorTestingTNewUserStore) *UserStore { + mock := &UserStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} -- GitLab