Adjust + Test
This commit is contained in:
@@ -18,34 +18,48 @@ type MockWorkspaceAccessor struct {
|
||||
workspace.Workspace
|
||||
}
|
||||
|
||||
func safeDBObject(v interface{}) utils.DBObject {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.(utils.DBObject)
|
||||
}
|
||||
|
||||
func safeShallowList(v interface{}) []utils.ShallowDBObject {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.([]utils.ShallowDBObject)
|
||||
}
|
||||
|
||||
func (m *MockWorkspaceAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
args := m.Called(data)
|
||||
return args.Get(0).(utils.DBObject), args.Int(1), args.Error(2)
|
||||
return safeDBObject(args.Get(0)), args.Int(1), args.Error(2)
|
||||
}
|
||||
|
||||
func (m *MockWorkspaceAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
||||
args := m.Called(set, id)
|
||||
return args.Get(0).(utils.DBObject), args.Int(1), args.Error(2)
|
||||
return safeDBObject(args.Get(0)), args.Int(1), args.Error(2)
|
||||
}
|
||||
|
||||
func (m *MockWorkspaceAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
args := m.Called(id)
|
||||
return args.Get(0).(utils.DBObject), args.Int(1), args.Error(2)
|
||||
return safeDBObject(args.Get(0)), args.Int(1), args.Error(2)
|
||||
}
|
||||
|
||||
func (m *MockWorkspaceAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
args := m.Called(id)
|
||||
return args.Get(0).(utils.DBObject), args.Int(1), args.Error(2)
|
||||
return safeDBObject(args.Get(0)), args.Int(1), args.Error(2)
|
||||
}
|
||||
|
||||
func (m *MockWorkspaceAccessor) LoadAll(isDraft bool) ([]utils.ShallowDBObject, int, error) {
|
||||
args := m.Called(isDraft)
|
||||
return args.Get(0).([]utils.ShallowDBObject), args.Int(1), args.Error(2)
|
||||
return safeShallowList(args.Get(0)), args.Int(1), args.Error(2)
|
||||
}
|
||||
|
||||
func (m *MockWorkspaceAccessor) Search(filters *dbs.Filters, search string, isDraft bool) ([]utils.ShallowDBObject, int, error) {
|
||||
args := m.Called(filters, search, isDraft)
|
||||
return args.Get(0).([]utils.ShallowDBObject), args.Int(1), args.Error(2)
|
||||
return safeShallowList(args.Get(0)), args.Int(1), args.Error(2)
|
||||
}
|
||||
|
||||
func TestStoreOne_Success(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user