mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Remove bus from quota, preferences, plugins, user_token (#44762)
* Remove bus from quota, preferences, plugins, user_token * Bind sqlstore.Store to *sqlstore.SQLStore * Fix test * Fix sqlstore wire injection, dependency
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type SQLStoreMock struct {
|
||||
SQLStore *sqlstore.SQLStore
|
||||
ExpectedUser *models.User
|
||||
ExpectedError error
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ func (m SQLStoreMock) CreateUser(ctx context.Context, cmd models.CreateUserComma
|
||||
}
|
||||
|
||||
func (m SQLStoreMock) GetUserById(ctx context.Context, query *models.GetUserByIdQuery) error {
|
||||
query.Result = m.ExpectedUser
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
@@ -150,7 +151,7 @@ func (m SQLStoreMock) DeleteUser(ctx context.Context, cmd *models.DeleteUserComm
|
||||
}
|
||||
|
||||
func (m SQLStoreMock) UpdateUserPermissions(userID int64, isAdmin bool) error {
|
||||
return nil // TODO: Implement
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
func (m SQLStoreMock) SetUserHelpFlag(ctx context.Context, cmd *models.SetUserHelpFlagCommand) error {
|
||||
@@ -158,7 +159,11 @@ func (m SQLStoreMock) SetUserHelpFlag(ctx context.Context, cmd *models.SetUserHe
|
||||
}
|
||||
|
||||
func (m SQLStoreMock) CreateTeam(name string, email string, orgID int64) (models.Team, error) {
|
||||
return models.Team{}, nil // TODO: Implement
|
||||
return models.Team{
|
||||
Name: name,
|
||||
Email: email,
|
||||
OrgId: orgID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m SQLStoreMock) UpdateTeam(ctx context.Context, cmd *models.UpdateTeamCommand) error {
|
||||
|
||||
@@ -30,7 +30,7 @@ func (ss *SQLStore) addUserQueryAndCommandHandlers() {
|
||||
bus.AddHandler("sql", ss.GetUserProfile)
|
||||
bus.AddHandler("sql", SearchUsers)
|
||||
bus.AddHandler("sql", ss.GetUserOrgList)
|
||||
bus.AddHandler("sql", DisableUser)
|
||||
bus.AddHandler("sql", ss.DisableUser)
|
||||
bus.AddHandler("sql", ss.BatchDisableUsers)
|
||||
bus.AddHandler("sql", ss.DeleteUser)
|
||||
bus.AddHandler("sql", ss.SetUserHelpFlag)
|
||||
@@ -320,7 +320,7 @@ func (ss *SQLStore) CreateUser(ctx context.Context, cmd models.CreateUserCommand
|
||||
return user, err
|
||||
}
|
||||
|
||||
func (ss *SQLStore) GetUserById(ctx context.Context, query *models.GetUserByIdQuery) error {
|
||||
func (ss SQLStore) GetUserById(ctx context.Context, query *models.GetUserByIdQuery) error {
|
||||
return withDbSession(ctx, x, func(sess *DBSession) error {
|
||||
user := new(models.User)
|
||||
has, err := sess.ID(query.Id).Get(user)
|
||||
@@ -721,7 +721,7 @@ func SearchUsers(ctx context.Context, query *models.SearchUsersQuery) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func DisableUser(ctx context.Context, cmd *models.DisableUserCommand) error {
|
||||
func (ss *SQLStore) DisableUser(ctx context.Context, cmd *models.DisableUserCommand) error {
|
||||
user := models.User{}
|
||||
sess := x.Table("user")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user