mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Bus: Tests cleanup (#46025)
* Delete unused bus from usagestats * Few updates to remove bus from searchusers test * Fix import
This commit is contained in:
@@ -3,8 +3,8 @@ package searchusers
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
)
|
||||
|
||||
type Service interface {
|
||||
@@ -13,12 +13,12 @@ type Service interface {
|
||||
}
|
||||
|
||||
type OSSService struct {
|
||||
bus bus.Bus
|
||||
sqlStore sqlstore.Store
|
||||
searchUserFilter models.SearchUserFilter
|
||||
}
|
||||
|
||||
func ProvideUsersService(bus bus.Bus, searchUserFilter models.SearchUserFilter) *OSSService {
|
||||
return &OSSService{bus: bus, searchUserFilter: searchUserFilter}
|
||||
func ProvideUsersService(sqlStore sqlstore.Store, searchUserFilter models.SearchUserFilter) *OSSService {
|
||||
return &OSSService{sqlStore: sqlStore, searchUserFilter: searchUserFilter}
|
||||
}
|
||||
|
||||
func (s *OSSService) SearchUsers(c *models.ReqContext) response.Response {
|
||||
@@ -60,7 +60,7 @@ func (s *OSSService) SearchUser(c *models.ReqContext) (*models.SearchUsersQuery,
|
||||
}
|
||||
|
||||
query := &models.SearchUsersQuery{Query: searchQuery, Filters: filters, Page: page, Limit: perPage}
|
||||
if err := s.bus.Dispatch(c.Req.Context(), query); err != nil {
|
||||
if err := s.sqlStore.SearchUsers(c.Req.Context(), query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ type SQLStoreMock struct {
|
||||
ExpectedDashboardSnapshot *models.DashboardSnapshot
|
||||
ExpectedTeamsByUser []*models.TeamDTO
|
||||
ExpectedSearchOrgList []*models.OrgDTO
|
||||
ExpectedSearchUsers models.SearchUserQueryResult
|
||||
ExpectedDatasources []*models.DataSource
|
||||
ExpectedOrg *models.Org
|
||||
ExpectedSystemStats *models.SystemStats
|
||||
@@ -193,6 +194,11 @@ func (m *SQLStoreMock) GetSignedInUser(ctx context.Context, query *models.GetSig
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
func (m *SQLStoreMock) SearchUsers(ctx context.Context, query *models.SearchUsersQuery) error {
|
||||
query.Result = m.ExpectedSearchUsers
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
func (m *SQLStoreMock) DisableUser(ctx context.Context, cmd *models.DisableUserCommand) error {
|
||||
m.LatestUserId = cmd.UserId
|
||||
return m.ExpectedError
|
||||
|
||||
@@ -42,6 +42,7 @@ type Store interface {
|
||||
GetUserOrgList(ctx context.Context, query *models.GetUserOrgListQuery) error
|
||||
GetSignedInUserWithCacheCtx(ctx context.Context, query *models.GetSignedInUserQuery) error
|
||||
GetSignedInUser(ctx context.Context, query *models.GetSignedInUserQuery) error
|
||||
SearchUsers(ctx context.Context, query *models.SearchUsersQuery) error
|
||||
DisableUser(ctx context.Context, cmd *models.DisableUserCommand) error
|
||||
BatchDisableUsers(ctx context.Context, cmd *models.BatchDisableUsersCommand) error
|
||||
DeleteUser(ctx context.Context, cmd *models.DeleteUserCommand) error
|
||||
|
||||
Reference in New Issue
Block a user