diff --git a/controller/mocks/Csbi.go b/controller/mocks/Csbi.go deleted file mode 100644 index 2857125c9cca0e9977c9832653c8ea809ac358c5..0000000000000000000000000000000000000000 --- a/controller/mocks/Csbi.go +++ /dev/null @@ -1,193 +0,0 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. -// It says DO NOT EDIT but it has been edited. :-) -// Combines a Plugin and a SouthboundInterface to represent a Csbi. - -package mocks - -import ( - gosdnsouthbound "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound" - plugin "code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin" - gnmi "github.com/openconfig/gnmi/proto/gnmi" - - mock "github.com/stretchr/testify/mock" - - uuid "github.com/google/uuid" - - yang "github.com/openconfig/goyang/pkg/yang" - - ygot "github.com/openconfig/ygot/ygot" - - ytypes "github.com/openconfig/ygot/ytypes" -) - -// Csbi is an autogenerated mock type for the Csbi type -type Csbi struct { - mock.Mock -} - -// ID provides a mock function with given fields: -func (_m *Csbi) 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 -} - -// Manifest provides a mock function with given fields: -func (_m *Csbi) Manifest() *plugin.Manifest { - ret := _m.Called() - - var r0 *plugin.Manifest - if rf, ok := ret.Get(0).(func() *plugin.Manifest); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*plugin.Manifest) - } - } - - return r0 -} - -// Path provides a mock function with given fields: -func (_m *Csbi) Path() 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 -} - -// State provides a mock function with given fields: -func (_m *Csbi) State() plugin.State { - ret := _m.Called() - - var r0 plugin.State - if rf, ok := ret.Get(0).(func() plugin.State); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(plugin.State) - } - - return r0 -} - -// Update provides a mock function with given fields: -func (_m *Csbi) Update() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Schema provides a mock function with given fields: -func (_m *Csbi) Schema() *ytypes.Schema { - ret := _m.Called() - - var r0 *ytypes.Schema - if rf, ok := ret.Get(0).(func() *ytypes.Schema); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ytypes.Schema) - } - } - - return r0 -} - -// SchemaTreeGzip provides a mock function with given fields: -func (_m *Csbi) SchemaTreeGzip() []byte { - ret := _m.Called() - - var r0 []byte - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - return r0 -} - -// SetID provides a mock function with given fields: id -func (_m *Csbi) SetID(id uuid.UUID) { - _m.Called(id) -} - -// SetNode provides a mock function with given fields: schema, root, path, val, opts -func (_m *Csbi) SetNode(schema *yang.Entry, root interface{}, path *gnmi.Path, val interface{}, opts ...ytypes.SetNodeOpt) error { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, schema, root, path, val) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 error - if rf, ok := ret.Get(0).(func(*yang.Entry, interface{}, *gnmi.Path, interface{}, ...ytypes.SetNodeOpt) error); ok { - r0 = rf(schema, root, path, val, opts...) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Type provides a mock function with given fields: -func (_m *Csbi) Type() gosdnsouthbound.Type { - ret := _m.Called() - - var r0 gosdnsouthbound.Type - if rf, ok := ret.Get(0).(func() gosdnsouthbound.Type); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(gosdnsouthbound.Type) - } - - return r0 -} - -// Unmarshal provides a mock function with given fields: _a0, _a1, _a2, _a3 -func (_m *Csbi) Unmarshal(_a0 []byte, _a1 *gnmi.Path, _a2 ygot.ValidatedGoStruct, _a3 ...ytypes.UnmarshalOpt) error { - _va := make([]interface{}, len(_a3)) - for _i := range _a3 { - _va[_i] = _a3[_i] - } - var _ca []interface{} - _ca = append(_ca, _a0, _a1, _a2) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 error - if rf, ok := ret.Get(0).(func([]byte, *gnmi.Path, ygot.ValidatedGoStruct, ...ytypes.UnmarshalOpt) error); ok { - r0 = rf(_a0, _a1, _a2, _a3...) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/controller/mocks/Device.go b/controller/mocks/Device.go deleted file mode 100644 index 9a3825ed6cb0af409f1a0329ee60ec9fe4cd7ece..0000000000000000000000000000000000000000 --- a/controller/mocks/Device.go +++ /dev/null @@ -1,181 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import ( - plugin "code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin" - mock "github.com/stretchr/testify/mock" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - - transport "code.fbi.h-da.de/danet/gosdn/controller/interfaces/transport" - - uuid "github.com/google/uuid" -) - -// Device is an autogenerated mock type for the Device type -type Device struct { - mock.Mock -} - -// GetModel provides a mock function with given fields: -func (_m *Device) GetModel() ([]byte, error) { - ret := _m.Called() - - var r0 []byte - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// 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 -} - -// GetPlugin provides a mock function with given fields: -func (_m *Device) GetPlugin() plugin.Plugin { - ret := _m.Called() - - var r0 plugin.Plugin - if rf, ok := ret.Get(0).(func() plugin.Plugin); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(plugin.Plugin) - } - } - - return r0 -} - -// ID provides a mock function with given fields: -func (_m *Device) 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 -} - -// IsTransportValid provides a mock function with given fields: -func (_m *Device) IsTransportValid() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// Name provides a mock function with given fields: -func (_m *Device) 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 -} - -// ProcessResponse provides a mock function with given fields: _a0 -func (_m *Device) ProcessResponse(_a0 protoreflect.ProtoMessage) error { - ret := _m.Called(_a0) - - var r0 error - if rf, ok := ret.Get(0).(func(protoreflect.ProtoMessage) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Transport provides a mock function with given fields: -func (_m *Device) Transport() transport.Transport { - ret := _m.Called() - - var r0 transport.Transport - if rf, ok := ret.Get(0).(func() transport.Transport); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(transport.Transport) - } - } - - return r0 -} - -// TransportAddress provides a mock function with given fields: -func (_m *Device) TransportAddress() 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 -} - -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) }) - - return mock -} diff --git a/controller/mocks/Plugin_additions.go b/controller/mocks/Plugin_additions.go index 64ba0043b8899152db393f8970b546da5611a177..33aba9076ad5c7ca7a6b6614040ea538059b9326 100644 --- a/controller/mocks/Plugin_additions.go +++ b/controller/mocks/Plugin_additions.go @@ -6,7 +6,7 @@ import ( uuid "github.com/google/uuid" ) -func (p *Plugin) MarshalJSON() ([]byte, error) { +func (p *PluginIface) MarshalJSON() ([]byte, error) { return json.Marshal(&struct { ID uuid.UUID `json:"id,omitempty"` }{ diff --git a/controller/mocks/RoleService.go b/controller/mocks/RoleService.go index abe04dae6270a7166a5bb61747a22b9750b8dfeb..78395b416fa649a09a4b451ae50f4e621e5b2efa 100644 --- a/controller/mocks/RoleService.go +++ b/controller/mocks/RoleService.go @@ -3,7 +3,6 @@ package mocks import ( - rbac "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" model "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" mock "github.com/stretchr/testify/mock" ) @@ -14,11 +13,11 @@ type RoleService struct { } // Add provides a mock function with given fields: _a0 -func (_m *RoleService) Add(_a0 rbac.Role) error { +func (_m *RoleService) Add(_a0 model.Role) error { ret := _m.Called(_a0) var r0 error - if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + if rf, ok := ret.Get(0).(func(model.Role) error); ok { r0 = rf(_a0) } else { r0 = ret.Error(0) @@ -28,11 +27,11 @@ func (_m *RoleService) Add(_a0 rbac.Role) error { } // Delete provides a mock function with given fields: _a0 -func (_m *RoleService) Delete(_a0 rbac.Role) error { +func (_m *RoleService) Delete(_a0 model.Role) error { ret := _m.Called(_a0) var r0 error - if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + if rf, ok := ret.Get(0).(func(model.Role) error); ok { r0 = rf(_a0) } else { r0 = ret.Error(0) @@ -42,20 +41,18 @@ func (_m *RoleService) Delete(_a0 rbac.Role) error { } // Get provides a mock function with given fields: _a0 -func (_m *RoleService) Get(_a0 model.Query) (rbac.Role, error) { +func (_m *RoleService) Get(_a0 model.Query) (model.Role, error) { ret := _m.Called(_a0) - var r0 rbac.Role + var r0 model.Role var r1 error - if rf, ok := ret.Get(0).(func(model.Query) (rbac.Role, error)); ok { + if rf, ok := ret.Get(0).(func(model.Query) (model.Role, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(model.Query) rbac.Role); ok { + if rf, ok := ret.Get(0).(func(model.Query) model.Role); ok { r0 = rf(_a0) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(rbac.Role) - } + r0 = ret.Get(0).(model.Role) } if rf, ok := ret.Get(1).(func(model.Query) error); ok { @@ -68,19 +65,19 @@ func (_m *RoleService) Get(_a0 model.Query) (rbac.Role, error) { } // GetAll provides a mock function with given fields: -func (_m *RoleService) GetAll() ([]rbac.Role, error) { +func (_m *RoleService) GetAll() ([]model.Role, error) { ret := _m.Called() - var r0 []rbac.Role + var r0 []model.Role var r1 error - if rf, ok := ret.Get(0).(func() ([]rbac.Role, error)); ok { + if rf, ok := ret.Get(0).(func() ([]model.Role, error)); ok { return rf() } - if rf, ok := ret.Get(0).(func() []rbac.Role); ok { + if rf, ok := ret.Get(0).(func() []model.Role); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]rbac.Role) + r0 = ret.Get(0).([]model.Role) } } @@ -94,11 +91,11 @@ func (_m *RoleService) GetAll() ([]rbac.Role, error) { } // Update provides a mock function with given fields: _a0 -func (_m *RoleService) Update(_a0 rbac.Role) error { +func (_m *RoleService) Update(_a0 model.Role) error { ret := _m.Called(_a0) var r0 error - if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + if rf, ok := ret.Get(0).(func(model.Role) error); ok { r0 = rf(_a0) } else { r0 = ret.Error(0) diff --git a/controller/mocks/RoleStore.go b/controller/mocks/RoleStore.go index 4912f4ca51ed32d8ae771e6ecc9b3794abf1c818..fb78c29b6100d9c9787db3e7b2ec594d924ce387 100644 --- a/controller/mocks/RoleStore.go +++ b/controller/mocks/RoleStore.go @@ -3,7 +3,6 @@ package mocks import ( - rbac "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" model "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" mock "github.com/stretchr/testify/mock" ) @@ -14,11 +13,11 @@ type RoleStore struct { } // Add provides a mock function with given fields: r -func (_m *RoleStore) Add(r rbac.Role) error { +func (_m *RoleStore) Add(r model.Role) error { ret := _m.Called(r) var r0 error - if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + if rf, ok := ret.Get(0).(func(model.Role) error); ok { r0 = rf(r) } else { r0 = ret.Error(0) @@ -28,11 +27,11 @@ func (_m *RoleStore) Add(r rbac.Role) error { } // Delete provides a mock function with given fields: _a0 -func (_m *RoleStore) Delete(_a0 rbac.Role) error { +func (_m *RoleStore) Delete(_a0 model.Role) error { ret := _m.Called(_a0) var r0 error - if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + if rf, ok := ret.Get(0).(func(model.Role) error); ok { r0 = rf(_a0) } else { r0 = ret.Error(0) @@ -42,18 +41,18 @@ func (_m *RoleStore) Delete(_a0 rbac.Role) error { } // Get provides a mock function with given fields: _a0 -func (_m *RoleStore) Get(_a0 model.Query) (rbac.LoadedRole, error) { +func (_m *RoleStore) Get(_a0 model.Query) (model.LoadedRole, error) { ret := _m.Called(_a0) - var r0 rbac.LoadedRole + var r0 model.LoadedRole var r1 error - if rf, ok := ret.Get(0).(func(model.Query) (rbac.LoadedRole, error)); ok { + if rf, ok := ret.Get(0).(func(model.Query) (model.LoadedRole, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(model.Query) rbac.LoadedRole); ok { + if rf, ok := ret.Get(0).(func(model.Query) model.LoadedRole); ok { r0 = rf(_a0) } else { - r0 = ret.Get(0).(rbac.LoadedRole) + r0 = ret.Get(0).(model.LoadedRole) } if rf, ok := ret.Get(1).(func(model.Query) error); ok { @@ -66,19 +65,19 @@ func (_m *RoleStore) Get(_a0 model.Query) (rbac.LoadedRole, error) { } // GetAll provides a mock function with given fields: -func (_m *RoleStore) GetAll() ([]rbac.LoadedRole, error) { +func (_m *RoleStore) GetAll() ([]model.LoadedRole, error) { ret := _m.Called() - var r0 []rbac.LoadedRole + var r0 []model.LoadedRole var r1 error - if rf, ok := ret.Get(0).(func() ([]rbac.LoadedRole, error)); ok { + if rf, ok := ret.Get(0).(func() ([]model.LoadedRole, error)); ok { return rf() } - if rf, ok := ret.Get(0).(func() []rbac.LoadedRole); ok { + if rf, ok := ret.Get(0).(func() []model.LoadedRole); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]rbac.LoadedRole) + r0 = ret.Get(0).([]model.LoadedRole) } } @@ -92,11 +91,11 @@ func (_m *RoleStore) GetAll() ([]rbac.LoadedRole, error) { } // Update provides a mock function with given fields: r -func (_m *RoleStore) Update(r rbac.Role) error { +func (_m *RoleStore) Update(r model.Role) error { ret := _m.Called(r) var r0 error - if rf, ok := ret.Get(0).(func(rbac.Role) error); ok { + if rf, ok := ret.Get(0).(func(model.Role) error); ok { r0 = rf(r) } else { r0 = ret.Error(0) diff --git a/controller/mocks/UserService.go b/controller/mocks/UserService.go index 56c1181da91329a854c3b7390f6fee8f35719282..f4409259d3f7910543e2cf944cc819bc82bb13c0 100644 --- a/controller/mocks/UserService.go +++ b/controller/mocks/UserService.go @@ -3,7 +3,6 @@ package mocks import ( - rbac "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" model "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" mock "github.com/stretchr/testify/mock" ) @@ -14,11 +13,11 @@ type UserService struct { } // Add provides a mock function with given fields: _a0 -func (_m *UserService) Add(_a0 rbac.User) error { +func (_m *UserService) Add(_a0 model.User) error { ret := _m.Called(_a0) var r0 error - if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + if rf, ok := ret.Get(0).(func(model.User) error); ok { r0 = rf(_a0) } else { r0 = ret.Error(0) @@ -28,11 +27,11 @@ func (_m *UserService) Add(_a0 rbac.User) error { } // Delete provides a mock function with given fields: _a0 -func (_m *UserService) Delete(_a0 rbac.User) error { +func (_m *UserService) Delete(_a0 model.User) error { ret := _m.Called(_a0) var r0 error - if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + if rf, ok := ret.Get(0).(func(model.User) error); ok { r0 = rf(_a0) } else { r0 = ret.Error(0) @@ -42,20 +41,18 @@ func (_m *UserService) Delete(_a0 rbac.User) error { } // Get provides a mock function with given fields: _a0 -func (_m *UserService) Get(_a0 model.Query) (rbac.User, error) { +func (_m *UserService) Get(_a0 model.Query) (model.User, error) { ret := _m.Called(_a0) - var r0 rbac.User + var r0 model.User var r1 error - if rf, ok := ret.Get(0).(func(model.Query) (rbac.User, error)); ok { + if rf, ok := ret.Get(0).(func(model.Query) (model.User, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(model.Query) rbac.User); ok { + if rf, ok := ret.Get(0).(func(model.Query) model.User); ok { r0 = rf(_a0) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(rbac.User) - } + r0 = ret.Get(0).(model.User) } if rf, ok := ret.Get(1).(func(model.Query) error); ok { @@ -68,19 +65,19 @@ func (_m *UserService) Get(_a0 model.Query) (rbac.User, error) { } // GetAll provides a mock function with given fields: -func (_m *UserService) GetAll() ([]rbac.User, error) { +func (_m *UserService) GetAll() ([]model.User, error) { ret := _m.Called() - var r0 []rbac.User + var r0 []model.User var r1 error - if rf, ok := ret.Get(0).(func() ([]rbac.User, error)); ok { + if rf, ok := ret.Get(0).(func() ([]model.User, error)); ok { return rf() } - if rf, ok := ret.Get(0).(func() []rbac.User); ok { + if rf, ok := ret.Get(0).(func() []model.User); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]rbac.User) + r0 = ret.Get(0).([]model.User) } } @@ -94,11 +91,11 @@ func (_m *UserService) GetAll() ([]rbac.User, error) { } // Update provides a mock function with given fields: _a0 -func (_m *UserService) Update(_a0 rbac.User) error { +func (_m *UserService) Update(_a0 model.User) error { ret := _m.Called(_a0) var r0 error - if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + if rf, ok := ret.Get(0).(func(model.User) error); ok { r0 = rf(_a0) } else { r0 = ret.Error(0) diff --git a/controller/mocks/UserStore.go b/controller/mocks/UserStore.go index c0676d5766b004bf7f07f8838fd51e2bb33e346b..a359e9d37afca78bf8a9042529b7c49c006e4d2f 100644 --- a/controller/mocks/UserStore.go +++ b/controller/mocks/UserStore.go @@ -3,7 +3,6 @@ package mocks import ( - rbac "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" model "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" mock "github.com/stretchr/testify/mock" ) @@ -14,11 +13,11 @@ type UserStore struct { } // Add provides a mock function with given fields: u -func (_m *UserStore) Add(u rbac.User) error { +func (_m *UserStore) Add(u model.User) error { ret := _m.Called(u) var r0 error - if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + if rf, ok := ret.Get(0).(func(model.User) error); ok { r0 = rf(u) } else { r0 = ret.Error(0) @@ -28,11 +27,11 @@ func (_m *UserStore) Add(u rbac.User) error { } // Delete provides a mock function with given fields: _a0 -func (_m *UserStore) Delete(_a0 rbac.User) error { +func (_m *UserStore) Delete(_a0 model.User) error { ret := _m.Called(_a0) var r0 error - if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + if rf, ok := ret.Get(0).(func(model.User) error); ok { r0 = rf(_a0) } else { r0 = ret.Error(0) @@ -42,18 +41,18 @@ func (_m *UserStore) Delete(_a0 rbac.User) error { } // Get provides a mock function with given fields: _a0 -func (_m *UserStore) Get(_a0 model.Query) (rbac.LoadedUser, error) { +func (_m *UserStore) Get(_a0 model.Query) (model.LoadedUser, error) { ret := _m.Called(_a0) - var r0 rbac.LoadedUser + var r0 model.LoadedUser var r1 error - if rf, ok := ret.Get(0).(func(model.Query) (rbac.LoadedUser, error)); ok { + if rf, ok := ret.Get(0).(func(model.Query) (model.LoadedUser, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(model.Query) rbac.LoadedUser); ok { + if rf, ok := ret.Get(0).(func(model.Query) model.LoadedUser); ok { r0 = rf(_a0) } else { - r0 = ret.Get(0).(rbac.LoadedUser) + r0 = ret.Get(0).(model.LoadedUser) } if rf, ok := ret.Get(1).(func(model.Query) error); ok { @@ -66,19 +65,19 @@ func (_m *UserStore) Get(_a0 model.Query) (rbac.LoadedUser, error) { } // GetAll provides a mock function with given fields: -func (_m *UserStore) GetAll() ([]rbac.LoadedUser, error) { +func (_m *UserStore) GetAll() ([]model.LoadedUser, error) { ret := _m.Called() - var r0 []rbac.LoadedUser + var r0 []model.LoadedUser var r1 error - if rf, ok := ret.Get(0).(func() ([]rbac.LoadedUser, error)); ok { + if rf, ok := ret.Get(0).(func() ([]model.LoadedUser, error)); ok { return rf() } - if rf, ok := ret.Get(0).(func() []rbac.LoadedUser); ok { + if rf, ok := ret.Get(0).(func() []model.LoadedUser); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]rbac.LoadedUser) + r0 = ret.Get(0).([]model.LoadedUser) } } @@ -92,11 +91,11 @@ func (_m *UserStore) GetAll() ([]rbac.LoadedUser, error) { } // Update provides a mock function with given fields: u -func (_m *UserStore) Update(u rbac.User) error { +func (_m *UserStore) Update(u model.User) error { ret := _m.Called(u) var r0 error - if rf, ok := ret.Get(0).(func(rbac.User) error); ok { + if rf, ok := ret.Get(0).(func(model.User) error); ok { r0 = rf(u) } else { r0 = ret.Error(0) diff --git a/controller/nucleus/pkg/persistence/filesystem/pluginFilesystemStore_test.go b/controller/nucleus/pkg/persistence/filesystem/pluginFilesystemStore_test.go index f7ff8c4b660c91886cb89884edfb4b58d9a34496..6cbcc389cd298ac6a05989accf47c897019a0a2b 100644 --- a/controller/nucleus/pkg/persistence/filesystem/pluginFilesystemStore_test.go +++ b/controller/nucleus/pkg/persistence/filesystem/pluginFilesystemStore_test.go @@ -3,11 +3,11 @@ package filesystem import ( "testing" - "code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin" "code.fbi.h-da.de/danet/gosdn/controller/mocks" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/domain/model" "code.fbi.h-da.de/danet/gosdn/controller/store" "github.com/google/uuid" + "github.com/stretchr/testify/mock" ) func ensureStoreFilesForTestsAreRemoved() { @@ -15,13 +15,31 @@ func ensureStoreFilesForTestsAreRemoved() { ensureStoreFileForTestsIsRemoved(store.NetworkElementFilenameSuffix) } +func mockPlugin(t testing.TB) model.PluginIface { + mockPlugin := &mocks.PluginIface{} + defaultPluginID := uuid.MustParse("b70c8425-68c7-4d4b-bb5e-5586572bd64b") + + mockPlugin.On("ID").Return(defaultPluginID) + mockPlugin.On("Unmarshal", mock.Anything, mock.Anything).Return(nil) + mockPlugin.On("Model", mock.Anything).Return([]byte( + "{\n\t\"Acl\": null,\n\t\"Bfd\": null,\n\t\"Components\": null,\n\t\"Interfaces\": null,\n\t\"Keychains\": null,\n\t\"Lldp\": null,\n\t\"Messages\": null,\n\t\"NetworkInstances\": null,\n\t\"RoutingPolicy\": null,\n\t\"System\": null\n}"), + nil, + ) + return mockPlugin +} + func TestAddPlugin(t *testing.T) { defer ensureStoreFilesForTestsAreRemoved() - pluginStore := NewPluginStore() + pluginStore := NewFilesystemPluginStore() mockPlugin := mockPlugin(t) - err := pluginStore.Add(mockPlugin) + plug, ok := mockPlugin.(*model.Plugin) + if !ok { + panic(ok) + } + + err := pluginStore.Add(plug) if err != nil { t.Error(err) } @@ -30,7 +48,7 @@ func TestAddPlugin(t *testing.T) { func TestGetAllPlugins(t *testing.T) { defer ensureStoreFilesForTestsAreRemoved() - pluginStore := NewPluginStore() + pluginStore := NewFilesystemPluginStore() mockPlugin1ID, err := uuid.Parse("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa") if err != nil { @@ -41,15 +59,20 @@ func TestGetAllPlugins(t *testing.T) { t.Error(err) } - mockPlugin1 := new(mocks.Plugin) - mockPlugin2 := new(mocks.Plugin) + mockPlugin1 := new(mocks.PluginIface) + mockPlugin2 := new(mocks.PluginIface) mockPlugin1.On("ID").Return(mockPlugin1ID) mockPlugin2.On("ID").Return(mockPlugin2ID) - inputPlugins := [2]plugin.Plugin{mockPlugin1, mockPlugin2} + inputPlugins := [2]model.PluginIface{mockPlugin1, mockPlugin2} for _, plugin := range inputPlugins { - err := pluginStore.Add(plugin) + plug, ok := plugin.(*model.Plugin) + if !ok { + panic(err) + } + + err := pluginStore.Add(plug) if err != nil { t.Error(err) } @@ -75,7 +98,7 @@ func TestGetAllPlugins(t *testing.T) { func TestGetPlugin(t *testing.T) { defer ensureStoreFilesForTestsAreRemoved() - pluginStore := NewPluginStore() + pluginStore := NewFilesystemPluginStore() mockPlugin1ID, err := uuid.Parse("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa") if err != nil { @@ -85,15 +108,20 @@ func TestGetPlugin(t *testing.T) { if err != nil { t.Error(err) } - mockPlugin1 := &mocks.Plugin{} + mockPlugin1 := &mocks.PluginIface{} mockPlugin1.On("ID").Return(mockPlugin1ID) - mockPlugin2 := &mocks.Plugin{} + mockPlugin2 := &mocks.PluginIface{} mockPlugin2.On("ID").Return(mockPlugin2ID) - inputPlugins := [2]plugin.Plugin{mockPlugin1, mockPlugin2} + inputPlugins := [2]model.PluginIface{mockPlugin1, mockPlugin2} + + for _, plugin := range inputPlugins { + plug, ok := plugin.(*model.Plugin) + if !ok { + panic(err) + } - for _, plugins := range inputPlugins { - err := pluginStore.Add(plugins) + err := pluginStore.Add(plug) if err != nil { t.Error(err) } @@ -112,7 +140,7 @@ func TestGetPlugin(t *testing.T) { func TestDeleteAllPlugins(t *testing.T) { defer ensureStoreFilesForTestsAreRemoved() - pluginStore := NewPluginStore() + pluginStore := NewFilesystemPluginStore() mockPlugin1ID, err := uuid.Parse("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa") if err != nil { @@ -123,20 +151,30 @@ func TestDeleteAllPlugins(t *testing.T) { t.Error(err) } mockPlugin1 := mockPlugin(t) - mockPlugin1.(*mocks.Plugin).On("ID").Return(mockPlugin1ID) + mockPlugin1.(*mocks.PluginIface).On("ID").Return(mockPlugin1ID) mockPlugin2 := mockPlugin(t) - mockPlugin2.(*mocks.Plugin).On("ID").Return(mockPlugin2ID) + mockPlugin2.(*mocks.PluginIface).On("ID").Return(mockPlugin2ID) - inputPlugins := [2]plugin.Plugin{mockPlugin1, mockPlugin2} + inputPlugins := [2]model.PluginIface{mockPlugin1, mockPlugin2} - for _, plugins := range inputPlugins { - err := pluginStore.Add(plugins) + for _, plugin := range inputPlugins { + plug, ok := plugin.(*model.Plugin) + if !ok { + panic(err) + } + + err := pluginStore.Add(plug) if err != nil { t.Error(err) } } - err = pluginStore.Delete(mockPlugin1) + plug, ok := mockPlugin1.(*model.Plugin) + if !ok { + panic(err) + } + + err = pluginStore.Delete(plug) if err != nil { t.Error(err) }