Automatic Merge
Этот коммит содержится в:
Rodrigo Villablanca
2020-08-04 10:37:21 -04:00
коммит произвёл GitHub
родитель 7a4d31c583
Коммит 86290685ae
13 изменённых файлов: 289 добавлений и 274 удалений

Просмотреть файл

@@ -32,7 +32,7 @@ func (s *LocalCacheRoleStore) handleClusterInvalidateRolePermissions(msg *model.
}
}
func (s LocalCacheRoleStore) Save(role *model.Role) (*model.Role, *model.AppError) {
func (s LocalCacheRoleStore) Save(role *model.Role) (*model.Role, error) {
if len(role.Name) != 0 {
defer s.rootStore.doInvalidateCacheCluster(s.rootStore.roleCache, role.Name)
defer s.rootStore.doClearCacheCluster(s.rootStore.rolePermissionsCache)
@@ -40,7 +40,7 @@ func (s LocalCacheRoleStore) Save(role *model.Role) (*model.Role, *model.AppErro
return s.RoleStore.Save(role)
}
func (s LocalCacheRoleStore) GetByName(name string) (*model.Role, *model.AppError) {
func (s LocalCacheRoleStore) GetByName(name string) (*model.Role, error) {
var role *model.Role
if err := s.rootStore.doStandardReadCache(s.rootStore.roleCache, name, &role); err == nil {
return role, nil
@@ -54,7 +54,7 @@ func (s LocalCacheRoleStore) GetByName(name string) (*model.Role, *model.AppErro
return role, nil
}
func (s LocalCacheRoleStore) GetByNames(names []string) ([]*model.Role, *model.AppError) {
func (s LocalCacheRoleStore) GetByNames(names []string) ([]*model.Role, error) {
var foundRoles []*model.Role
var rolesToQuery []string
@@ -76,7 +76,7 @@ func (s LocalCacheRoleStore) GetByNames(names []string) ([]*model.Role, *model.A
return append(foundRoles, roles...), nil
}
func (s LocalCacheRoleStore) Delete(roleId string) (*model.Role, *model.AppError) {
func (s LocalCacheRoleStore) Delete(roleId string) (*model.Role, error) {
role, err := s.RoleStore.Delete(roleId)
if err == nil {
@@ -86,7 +86,7 @@ func (s LocalCacheRoleStore) Delete(roleId string) (*model.Role, *model.AppError
return role, err
}
func (s LocalCacheRoleStore) PermanentDeleteAll() *model.AppError {
func (s LocalCacheRoleStore) PermanentDeleteAll() error {
defer s.rootStore.roleCache.Purge()
defer s.rootStore.doClearCacheCluster(s.rootStore.roleCache)
defer s.rootStore.doClearCacheCluster(s.rootStore.rolePermissionsCache)
@@ -94,7 +94,7 @@ func (s LocalCacheRoleStore) PermanentDeleteAll() *model.AppError {
return s.RoleStore.PermanentDeleteAll()
}
func (s LocalCacheRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, *model.AppError) {
func (s LocalCacheRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error) {
sort.Strings(roleNames)
cacheKey := strings.Join(roleNames, "/")
var rolePermissionsMap map[string]*model.RolePermissions

Просмотреть файл

@@ -5617,7 +5617,7 @@ func (s *OpenTracingLayerReactionStore) Save(reaction *model.Reaction) (*model.R
return resultVar0, resultVar1
}
func (s *OpenTracingLayerRoleStore) AllChannelSchemeRoles() ([]*model.Role, *model.AppError) {
func (s *OpenTracingLayerRoleStore) AllChannelSchemeRoles() ([]*model.Role, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.AllChannelSchemeRoles")
s.Root.Store.SetContext(newCtx)
@@ -5635,7 +5635,7 @@ func (s *OpenTracingLayerRoleStore) AllChannelSchemeRoles() ([]*model.Role, *mod
return resultVar0, resultVar1
}
func (s *OpenTracingLayerRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, *model.AppError) {
func (s *OpenTracingLayerRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.ChannelHigherScopedPermissions")
s.Root.Store.SetContext(newCtx)
@@ -5653,7 +5653,7 @@ func (s *OpenTracingLayerRoleStore) ChannelHigherScopedPermissions(roleNames []s
return resultVar0, resultVar1
}
func (s *OpenTracingLayerRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, *model.AppError) {
func (s *OpenTracingLayerRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.ChannelRolesUnderTeamRole")
s.Root.Store.SetContext(newCtx)
@@ -5671,7 +5671,7 @@ func (s *OpenTracingLayerRoleStore) ChannelRolesUnderTeamRole(roleName string) (
return resultVar0, resultVar1
}
func (s *OpenTracingLayerRoleStore) Delete(roleId string) (*model.Role, *model.AppError) {
func (s *OpenTracingLayerRoleStore) Delete(roleId string) (*model.Role, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.Delete")
s.Root.Store.SetContext(newCtx)
@@ -5689,7 +5689,7 @@ func (s *OpenTracingLayerRoleStore) Delete(roleId string) (*model.Role, *model.A
return resultVar0, resultVar1
}
func (s *OpenTracingLayerRoleStore) Get(roleId string) (*model.Role, *model.AppError) {
func (s *OpenTracingLayerRoleStore) Get(roleId string) (*model.Role, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.Get")
s.Root.Store.SetContext(newCtx)
@@ -5707,7 +5707,7 @@ func (s *OpenTracingLayerRoleStore) Get(roleId string) (*model.Role, *model.AppE
return resultVar0, resultVar1
}
func (s *OpenTracingLayerRoleStore) GetAll() ([]*model.Role, *model.AppError) {
func (s *OpenTracingLayerRoleStore) GetAll() ([]*model.Role, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.GetAll")
s.Root.Store.SetContext(newCtx)
@@ -5725,7 +5725,7 @@ func (s *OpenTracingLayerRoleStore) GetAll() ([]*model.Role, *model.AppError) {
return resultVar0, resultVar1
}
func (s *OpenTracingLayerRoleStore) GetByName(name string) (*model.Role, *model.AppError) {
func (s *OpenTracingLayerRoleStore) GetByName(name string) (*model.Role, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.GetByName")
s.Root.Store.SetContext(newCtx)
@@ -5743,7 +5743,7 @@ func (s *OpenTracingLayerRoleStore) GetByName(name string) (*model.Role, *model.
return resultVar0, resultVar1
}
func (s *OpenTracingLayerRoleStore) GetByNames(names []string) ([]*model.Role, *model.AppError) {
func (s *OpenTracingLayerRoleStore) GetByNames(names []string) ([]*model.Role, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.GetByNames")
s.Root.Store.SetContext(newCtx)
@@ -5761,7 +5761,7 @@ func (s *OpenTracingLayerRoleStore) GetByNames(names []string) ([]*model.Role, *
return resultVar0, resultVar1
}
func (s *OpenTracingLayerRoleStore) PermanentDeleteAll() *model.AppError {
func (s *OpenTracingLayerRoleStore) PermanentDeleteAll() error {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.PermanentDeleteAll")
s.Root.Store.SetContext(newCtx)
@@ -5779,7 +5779,7 @@ func (s *OpenTracingLayerRoleStore) PermanentDeleteAll() *model.AppError {
return resultVar0
}
func (s *OpenTracingLayerRoleStore) Save(role *model.Role) (*model.Role, *model.AppError) {
func (s *OpenTracingLayerRoleStore) Save(role *model.Role) (*model.Role, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "RoleStore.Save")
s.Root.Store.SetContext(newCtx)

Просмотреть файл

@@ -6,7 +6,6 @@ package sqlstore
import (
"database/sql"
"fmt"
"net/http"
"strings"
sq "github.com/Masterminds/squirrel"
@@ -97,24 +96,24 @@ func newSqlRoleStore(sqlStore SqlStore) store.RoleStore {
return s
}
func (s *SqlRoleStore) Save(role *model.Role) (*model.Role, *model.AppError) {
func (s *SqlRoleStore) Save(role *model.Role) (*model.Role, error) {
// Check the role is valid before proceeding.
if !role.IsValidWithoutId() {
return nil, model.NewAppError("SqlRoleStore.Save", "store.sql_role.save.invalid_role.app_error", nil, "", http.StatusBadRequest)
return nil, store.NewErrInvalidInput("Role", "<any>", fmt.Sprintf("%v", role))
}
if len(role.Id) == 0 {
transaction, err := s.GetMaster().Begin()
if err != nil {
return nil, model.NewAppError("SqlRoleStore.RoleSave", "store.sql_role.save.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "begin_transaction")
}
defer finalizeTransaction(transaction)
createdRole, err := s.createRole(role, transaction)
if err != nil {
transaction.Rollback()
return nil, model.NewAppError("SqlRoleStore.RoleSave", "store.sql_role.save.insert.app_error", nil, err.Error(), http.StatusInternalServerError)
_ = transaction.Rollback()
return nil, errors.Wrap(err, "unable to create Role")
} else if err := transaction.Commit(); err != nil {
return nil, model.NewAppError("SqlRoleStore.RoleSave", "store.sql_role.save_role.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "commit_transaction")
}
return createdRole, nil
}
@@ -122,9 +121,9 @@ func (s *SqlRoleStore) Save(role *model.Role) (*model.Role, *model.AppError) {
dbRole := NewRoleFromModel(role)
dbRole.UpdateAt = model.GetMillis()
if rowsChanged, err := s.GetMaster().Update(dbRole); err != nil {
return nil, model.NewAppError("SqlRoleStore.Save", "store.sql_role.save.update.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "failed to update Role")
} else if rowsChanged != 1 {
return nil, model.NewAppError("SqlRoleStore.Save", "store.sql_role.save.update.app_error", nil, "no record to update", http.StatusInternalServerError)
return nil, fmt.Errorf("invalid number of updated rows, expected 1 but got %d", rowsChanged)
}
return dbRole.ToModel(), nil
@@ -149,27 +148,24 @@ func (s *SqlRoleStore) createRole(role *model.Role, transaction *gorp.Transactio
return dbRole.ToModel(), nil
}
func (s *SqlRoleStore) Get(roleId string) (*model.Role, *model.AppError) {
func (s *SqlRoleStore) Get(roleId string) (*model.Role, error) {
var dbRole Role
if err := s.GetReplica().SelectOne(&dbRole, "SELECT * from Roles WHERE Id = :Id", map[string]interface{}{"Id": roleId}); err != nil {
if err == sql.ErrNoRows {
return nil, model.NewAppError("SqlRoleStore.Get", "store.sql_role.get.app_error", nil, "Id="+roleId+", "+err.Error(), http.StatusNotFound)
return nil, store.NewErrNotFound("Role", roleId)
}
return nil, model.NewAppError("SqlRoleStore.Get", "store.sql_role.get.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "failed to get Role")
}
return dbRole.ToModel(), nil
}
func (s *SqlRoleStore) GetAll() ([]*model.Role, *model.AppError) {
func (s *SqlRoleStore) GetAll() ([]*model.Role, error) {
var dbRoles []Role
if _, err := s.GetReplica().Select(&dbRoles, "SELECT * from Roles", map[string]interface{}{}); err != nil {
if err == sql.ErrNoRows {
return nil, model.NewAppError("SqlRoleStore.GetAll", "store.sql_role.get_all.app_error", nil, err.Error(), http.StatusNotFound)
}
return nil, model.NewAppError("SqlRoleStore.GetAll", "store.sql_role.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "failed to find Roles")
}
var roles []*model.Role
@@ -179,40 +175,36 @@ func (s *SqlRoleStore) GetAll() ([]*model.Role, *model.AppError) {
return roles, nil
}
func (s *SqlRoleStore) GetByName(name string) (*model.Role, *model.AppError) {
func (s *SqlRoleStore) GetByName(name string) (*model.Role, error) {
var dbRole Role
if err := s.GetReplica().SelectOne(&dbRole, "SELECT * from Roles WHERE Name = :Name", map[string]interface{}{"Name": name}); err != nil {
if err == sql.ErrNoRows {
return nil, model.NewAppError("SqlRoleStore.GetByName", "store.sql_role.get_by_name.app_error", nil, "name="+name+",err="+err.Error(), http.StatusNotFound)
return nil, store.NewErrNotFound("Role", fmt.Sprintf("name=%s", name))
}
return nil, model.NewAppError("SqlRoleStore.GetByName", "store.sql_role.get_by_name.app_error", nil, "name="+name+",err="+err.Error(), http.StatusInternalServerError)
return nil, errors.Wrapf(err, "failed to find Roles with name=%s", name)
}
return dbRole.ToModel(), nil
}
func (s *SqlRoleStore) GetByNames(names []string) ([]*model.Role, *model.AppError) {
func (s *SqlRoleStore) GetByNames(names []string) ([]*model.Role, error) {
if len(names) == 0 {
return []*model.Role{}, nil
}
failure := func(e error) ([]*model.Role, *model.AppError) {
return nil, model.NewAppError("SqlRoleStore.GetByNames", "store.sql_role.get_by_names.app_error", nil, e.Error(), http.StatusInternalServerError)
}
query := s.getQueryBuilder().
Select("Id, Name, DisplayName, Description, CreateAt, UpdateAt, DeleteAt, Permissions, SchemeManaged, BuiltIn").
From("Roles").
Where(sq.Eq{"Name": names})
queryString, args, err := query.ToSql()
if err != nil {
return failure(err)
return nil, errors.Wrap(err, "role_tosql")
}
rows, err := s.GetReplica().Db.Query(queryString, args...)
if err != nil {
return failure(err)
return nil, errors.Wrap(err, "failed to find Roles")
}
var roles []*model.Role
@@ -224,26 +216,25 @@ func (s *SqlRoleStore) GetByNames(names []string) ([]*model.Role, *model.AppErro
&role.CreateAt, &role.UpdateAt, &role.DeleteAt, &role.Permissions,
&role.SchemeManaged, &role.BuiltIn)
if err != nil {
return failure(err)
return nil, errors.Wrap(err, "failed to scan values")
}
roles = append(roles, role.ToModel())
}
err = rows.Err()
if err != nil {
return failure(err)
if err = rows.Err(); err != nil {
return nil, errors.Wrap(err, "unable to iterate over rows")
}
return roles, nil
}
func (s *SqlRoleStore) Delete(roleId string) (*model.Role, *model.AppError) {
func (s *SqlRoleStore) Delete(roleId string) (*model.Role, error) {
// Get the role.
var role *Role
if err := s.GetReplica().SelectOne(&role, "SELECT * from Roles WHERE Id = :Id", map[string]interface{}{"Id": roleId}); err != nil {
if err == sql.ErrNoRows {
return nil, model.NewAppError("SqlRoleStore.Delete", "store.sql_role.get.app_error", nil, "Id="+roleId+", "+err.Error(), http.StatusNotFound)
return nil, store.NewErrNotFound("Role", roleId)
}
return nil, model.NewAppError("SqlRoleStore.Delete", "store.sql_role.get.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrapf(err, "failed to get Role with id=%s", roleId)
}
time := model.GetMillis()
@@ -251,16 +242,16 @@ func (s *SqlRoleStore) Delete(roleId string) (*model.Role, *model.AppError) {
role.UpdateAt = time
if rowsChanged, err := s.GetMaster().Update(role); err != nil {
return nil, model.NewAppError("SqlRoleStore.Delete", "store.sql_role.delete.update.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "failed to update Role")
} else if rowsChanged != 1 {
return nil, model.NewAppError("SqlRoleStore.Delete", "store.sql_role.delete.update.app_error", nil, "no record to update", http.StatusInternalServerError)
return nil, errors.Wrapf(err, "invalid number of updated rows, expected 1 but got %d", rowsChanged)
}
return role.ToModel(), nil
}
func (s *SqlRoleStore) PermanentDeleteAll() *model.AppError {
func (s *SqlRoleStore) PermanentDeleteAll() error {
if _, err := s.GetMaster().Exec("DELETE FROM Roles"); err != nil {
return model.NewAppError("SqlRoleStore.PermanentDeleteAll", "store.sql_role.permanent_delete_all.app_error", nil, err.Error(), http.StatusInternalServerError)
return errors.Wrap(err, "failed to delete Roles")
}
return nil
@@ -340,12 +331,12 @@ func (s *SqlRoleStore) channelHigherScopedPermissionsQuery(roleNames []string) s
)
}
func (s *SqlRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, *model.AppError) {
sql := s.channelHigherScopedPermissionsQuery(roleNames)
func (s *SqlRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error) {
query := s.channelHigherScopedPermissionsQuery(roleNames)
var rolesPermissions []*channelRolesPermissions
if _, err := s.GetReplica().Select(&rolesPermissions, sql); err != nil {
return nil, model.NewAppError("SqlRoleStore.HigherScopedPermissions", "store.sql_role.get_by_names.app_error", nil, err.Error(), http.StatusInternalServerError)
if _, err := s.GetReplica().Select(&rolesPermissions, query); err != nil {
return nil, errors.Wrap(err, "failed to find RolePermissions")
}
roleNameHigherScopedPermissions := map[string]*model.RolePermissions{}
@@ -359,7 +350,7 @@ func (s *SqlRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[s
return roleNameHigherScopedPermissions, nil
}
func (s *SqlRoleStore) AllChannelSchemeRoles() ([]*model.Role, *model.AppError) {
func (s *SqlRoleStore) AllChannelSchemeRoles() ([]*model.Role, error) {
query := s.getQueryBuilder().
Select("Roles.*").
From("Schemes").
@@ -370,12 +361,12 @@ func (s *SqlRoleStore) AllChannelSchemeRoles() ([]*model.Role, *model.AppError)
queryString, args, err := query.ToSql()
if err != nil {
return nil, model.NewAppError("SqlRoleStore.AllChannelSchemeManagedRoles", "store.sql.build_query.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "role_tosql")
}
var dbRoles []*Role
if _, err = s.GetReplica().Select(&dbRoles, queryString, args...); err != nil {
return nil, model.NewAppError("SqlRoleStore.AllChannelSchemeManagedRoles", "store.sql_role.get.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "failed to find Roles")
}
var roles []*model.Role
@@ -387,7 +378,7 @@ func (s *SqlRoleStore) AllChannelSchemeRoles() ([]*model.Role, *model.AppError)
}
// ChannelRolesUnderTeamRole finds all of the channel-scheme roles under the team of the given team-scheme role.
func (s *SqlRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, *model.AppError) {
func (s *SqlRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, error) {
query := s.getQueryBuilder().
Select("ChannelSchemeRoles.*").
From("Roles AS HigherScopedRoles").
@@ -407,12 +398,12 @@ func (s *SqlRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role
queryString, args, err := query.ToSql()
if err != nil {
return nil, model.NewAppError("SqlRoleStore.ChannelRolesUnderTeamRole", "store.sql.build_query.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "role_tosql")
}
var dbRoles []*Role
if _, err = s.GetReplica().Select(&dbRoles, queryString, args...); err != nil {
return nil, model.NewAppError("SqlRoleStore.ChannelRolesUnderTeamRole", "store.sql_role.get.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, errors.Wrap(err, "failed to find Roles")
}
var roles []*model.Role

Просмотреть файл

@@ -603,24 +603,24 @@ type PluginStore interface {
}
type RoleStore interface {
Save(role *model.Role) (*model.Role, *model.AppError)
Get(roleId string) (*model.Role, *model.AppError)
GetAll() ([]*model.Role, *model.AppError)
GetByName(name string) (*model.Role, *model.AppError)
GetByNames(names []string) ([]*model.Role, *model.AppError)
Delete(roleId string) (*model.Role, *model.AppError)
PermanentDeleteAll() *model.AppError
Save(role *model.Role) (*model.Role, error)
Get(roleId string) (*model.Role, error)
GetAll() ([]*model.Role, error)
GetByName(name string) (*model.Role, error)
GetByNames(names []string) ([]*model.Role, error)
Delete(roleId string) (*model.Role, error)
PermanentDeleteAll() error
// HigherScopedPermissions retrieves the higher-scoped permissions of a list of role names. The higher-scope
// (either team scheme or system scheme) is determined based on whether the team has a scheme or not.
ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, *model.AppError)
ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error)
// AllChannelSchemeRoles returns all of the roles associated to channel schemes.
AllChannelSchemeRoles() ([]*model.Role, *model.AppError)
AllChannelSchemeRoles() ([]*model.Role, error)
// ChannelRolesUnderTeamRole returns all of the non-deleted roles that are affected by updates to the
// given role.
ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, *model.AppError)
ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, error)
}
type SchemeStore interface {

Просмотреть файл

@@ -15,7 +15,7 @@ type RoleStore struct {
}
// AllChannelSchemeRoles provides a mock function with given fields:
func (_m *RoleStore) AllChannelSchemeRoles() ([]*model.Role, *model.AppError) {
func (_m *RoleStore) AllChannelSchemeRoles() ([]*model.Role, error) {
ret := _m.Called()
var r0 []*model.Role
@@ -27,20 +27,18 @@ func (_m *RoleStore) AllChannelSchemeRoles() ([]*model.Role, *model.AppError) {
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func() *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// ChannelHigherScopedPermissions provides a mock function with given fields: roleNames
func (_m *RoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, *model.AppError) {
func (_m *RoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error) {
ret := _m.Called(roleNames)
var r0 map[string]*model.RolePermissions
@@ -52,20 +50,18 @@ func (_m *RoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[str
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func([]string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func([]string) error); ok {
r1 = rf(roleNames)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// ChannelRolesUnderTeamRole provides a mock function with given fields: roleName
func (_m *RoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, *model.AppError) {
func (_m *RoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, error) {
ret := _m.Called(roleName)
var r0 []*model.Role
@@ -77,20 +73,18 @@ func (_m *RoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role,
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(roleName)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// Delete provides a mock function with given fields: roleId
func (_m *RoleStore) Delete(roleId string) (*model.Role, *model.AppError) {
func (_m *RoleStore) Delete(roleId string) (*model.Role, error) {
ret := _m.Called(roleId)
var r0 *model.Role
@@ -102,20 +96,18 @@ func (_m *RoleStore) Delete(roleId string) (*model.Role, *model.AppError) {
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(roleId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// Get provides a mock function with given fields: roleId
func (_m *RoleStore) Get(roleId string) (*model.Role, *model.AppError) {
func (_m *RoleStore) Get(roleId string) (*model.Role, error) {
ret := _m.Called(roleId)
var r0 *model.Role
@@ -127,20 +119,18 @@ func (_m *RoleStore) Get(roleId string) (*model.Role, *model.AppError) {
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(roleId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// GetAll provides a mock function with given fields:
func (_m *RoleStore) GetAll() ([]*model.Role, *model.AppError) {
func (_m *RoleStore) GetAll() ([]*model.Role, error) {
ret := _m.Called()
var r0 []*model.Role
@@ -152,20 +142,18 @@ func (_m *RoleStore) GetAll() ([]*model.Role, *model.AppError) {
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func() *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// GetByName provides a mock function with given fields: name
func (_m *RoleStore) GetByName(name string) (*model.Role, *model.AppError) {
func (_m *RoleStore) GetByName(name string) (*model.Role, error) {
ret := _m.Called(name)
var r0 *model.Role
@@ -177,20 +165,18 @@ func (_m *RoleStore) GetByName(name string) (*model.Role, *model.AppError) {
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(name)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// GetByNames provides a mock function with given fields: names
func (_m *RoleStore) GetByNames(names []string) ([]*model.Role, *model.AppError) {
func (_m *RoleStore) GetByNames(names []string) ([]*model.Role, error) {
ret := _m.Called(names)
var r0 []*model.Role
@@ -202,36 +188,32 @@ func (_m *RoleStore) GetByNames(names []string) ([]*model.Role, *model.AppError)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func([]string) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func([]string) error); ok {
r1 = rf(names)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1
}
// PermanentDeleteAll provides a mock function with given fields:
func (_m *RoleStore) PermanentDeleteAll() *model.AppError {
func (_m *RoleStore) PermanentDeleteAll() error {
ret := _m.Called()
var r0 *model.AppError
if rf, ok := ret.Get(0).(func() *model.AppError); ok {
var r0 error
if rf, ok := ret.Get(0).(func() error); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
r0 = ret.Error(0)
}
return r0
}
// Save provides a mock function with given fields: role
func (_m *RoleStore) Save(role *model.Role) (*model.Role, *model.AppError) {
func (_m *RoleStore) Save(role *model.Role) (*model.Role, error) {
ret := _m.Called(role)
var r0 *model.Role
@@ -243,13 +225,11 @@ func (_m *RoleStore) Save(role *model.Role) (*model.Role, *model.AppError) {
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(*model.Role) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(*model.Role) error); ok {
r1 = rf(role)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1

Просмотреть файл

@@ -537,7 +537,7 @@ func testCountWithoutPermission(t *testing.T, ss store.Store) {
}
getRoles := func(scheme *model.Scheme) (channelUser, channelGuest *model.Role) {
var err *model.AppError
var err error
channelUser, err = ss.Role().GetByName(scheme.DefaultChannelUserRole)
require.Nil(t, err)
require.NotNil(t, channelUser)

Просмотреть файл

@@ -5085,7 +5085,7 @@ func (s *TimerLayerReactionStore) Save(reaction *model.Reaction) (*model.Reactio
return resultVar0, resultVar1
}
func (s *TimerLayerRoleStore) AllChannelSchemeRoles() ([]*model.Role, *model.AppError) {
func (s *TimerLayerRoleStore) AllChannelSchemeRoles() ([]*model.Role, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.RoleStore.AllChannelSchemeRoles()
@@ -5101,7 +5101,7 @@ func (s *TimerLayerRoleStore) AllChannelSchemeRoles() ([]*model.Role, *model.App
return resultVar0, resultVar1
}
func (s *TimerLayerRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, *model.AppError) {
func (s *TimerLayerRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.RoleStore.ChannelHigherScopedPermissions(roleNames)
@@ -5117,7 +5117,7 @@ func (s *TimerLayerRoleStore) ChannelHigherScopedPermissions(roleNames []string)
return resultVar0, resultVar1
}
func (s *TimerLayerRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, *model.AppError) {
func (s *TimerLayerRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.RoleStore.ChannelRolesUnderTeamRole(roleName)
@@ -5133,7 +5133,7 @@ func (s *TimerLayerRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*mod
return resultVar0, resultVar1
}
func (s *TimerLayerRoleStore) Delete(roleId string) (*model.Role, *model.AppError) {
func (s *TimerLayerRoleStore) Delete(roleId string) (*model.Role, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.RoleStore.Delete(roleId)
@@ -5149,7 +5149,7 @@ func (s *TimerLayerRoleStore) Delete(roleId string) (*model.Role, *model.AppErro
return resultVar0, resultVar1
}
func (s *TimerLayerRoleStore) Get(roleId string) (*model.Role, *model.AppError) {
func (s *TimerLayerRoleStore) Get(roleId string) (*model.Role, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.RoleStore.Get(roleId)
@@ -5165,7 +5165,7 @@ func (s *TimerLayerRoleStore) Get(roleId string) (*model.Role, *model.AppError)
return resultVar0, resultVar1
}
func (s *TimerLayerRoleStore) GetAll() ([]*model.Role, *model.AppError) {
func (s *TimerLayerRoleStore) GetAll() ([]*model.Role, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.RoleStore.GetAll()
@@ -5181,7 +5181,7 @@ func (s *TimerLayerRoleStore) GetAll() ([]*model.Role, *model.AppError) {
return resultVar0, resultVar1
}
func (s *TimerLayerRoleStore) GetByName(name string) (*model.Role, *model.AppError) {
func (s *TimerLayerRoleStore) GetByName(name string) (*model.Role, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.RoleStore.GetByName(name)
@@ -5197,7 +5197,7 @@ func (s *TimerLayerRoleStore) GetByName(name string) (*model.Role, *model.AppErr
return resultVar0, resultVar1
}
func (s *TimerLayerRoleStore) GetByNames(names []string) ([]*model.Role, *model.AppError) {
func (s *TimerLayerRoleStore) GetByNames(names []string) ([]*model.Role, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.RoleStore.GetByNames(names)
@@ -5213,7 +5213,7 @@ func (s *TimerLayerRoleStore) GetByNames(names []string) ([]*model.Role, *model.
return resultVar0, resultVar1
}
func (s *TimerLayerRoleStore) PermanentDeleteAll() *model.AppError {
func (s *TimerLayerRoleStore) PermanentDeleteAll() error {
start := timemodule.Now()
resultVar0 := s.RoleStore.PermanentDeleteAll()
@@ -5229,7 +5229,7 @@ func (s *TimerLayerRoleStore) PermanentDeleteAll() *model.AppError {
return resultVar0
}
func (s *TimerLayerRoleStore) Save(role *model.Role) (*model.Role, *model.AppError) {
func (s *TimerLayerRoleStore) Save(role *model.Role) (*model.Role, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.RoleStore.Save(role)