mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
@@ -27,6 +27,7 @@ type SQLStoreMock struct {
|
||||
ExpectedOrgListResponse OrgListResponse
|
||||
ExpectedDashboardSnapshot *models.DashboardSnapshot
|
||||
ExpectedTeamsByUser []*models.TeamDTO
|
||||
ExpectedSearchOrgList []*models.OrgDTO
|
||||
ExpectedError error
|
||||
}
|
||||
|
||||
@@ -628,3 +629,8 @@ func (m *SQLStoreMock) ExpireOldUserInvites(ctx context.Context, cmd *models.Exp
|
||||
func (m *SQLStoreMock) GetDBHealthQuery(ctx context.Context, query *models.GetDBHealthQuery) error {
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
func (m *SQLStoreMock) SearchOrgs(ctx context.Context, query *models.SearchOrgsQuery) error {
|
||||
query.Result = m.ExpectedSearchOrgList
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ func (ss *SQLStore) addOrgQueryAndCommandHandlers() {
|
||||
bus.AddHandler("sql", ss.UpdateOrg)
|
||||
bus.AddHandler("sql", ss.UpdateOrgAddress)
|
||||
bus.AddHandler("sql", GetOrgByName)
|
||||
bus.AddHandler("sql", SearchOrgs)
|
||||
bus.AddHandler("sql", ss.SearchOrgs)
|
||||
bus.AddHandler("sql", ss.DeleteOrg)
|
||||
}
|
||||
|
||||
func SearchOrgs(ctx context.Context, query *models.SearchOrgsQuery) error {
|
||||
func (ss *SQLStore) SearchOrgs(ctx context.Context, query *models.SearchOrgsQuery) error {
|
||||
query.Result = make([]*models.OrgDTO, 0)
|
||||
sess := x.Table("org")
|
||||
if query.Query != "" {
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestAccountDataAccess(t *testing.T) {
|
||||
}
|
||||
|
||||
query := &models.SearchOrgsQuery{Ids: ids}
|
||||
err = SearchOrgs(context.Background(), query)
|
||||
err = sqlStore.SearchOrgs(context.Background(), query)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(query.Result), 3)
|
||||
@@ -48,7 +48,7 @@ func TestAccountDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Should be able to search with defaults", func(t *testing.T) {
|
||||
query := &models.SearchOrgsQuery{}
|
||||
err := SearchOrgs(context.Background(), query)
|
||||
err := sqlStore.SearchOrgs(context.Background(), query)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(query.Result), 3)
|
||||
@@ -56,7 +56,7 @@ func TestAccountDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Should be able to limit search", func(t *testing.T) {
|
||||
query := &models.SearchOrgsQuery{Limit: 1}
|
||||
err := SearchOrgs(context.Background(), query)
|
||||
err := sqlStore.SearchOrgs(context.Background(), query)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(query.Result), 1)
|
||||
@@ -64,7 +64,7 @@ func TestAccountDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Should be able to limit and paginate search", func(t *testing.T) {
|
||||
query := &models.SearchOrgsQuery{Limit: 2, Page: 1}
|
||||
err := SearchOrgs(context.Background(), query)
|
||||
err := sqlStore.SearchOrgs(context.Background(), query)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(query.Result), 1)
|
||||
|
||||
@@ -151,4 +151,5 @@ type Store interface {
|
||||
GetTempUserByCode(ctx context.Context, query *models.GetTempUserByCodeQuery) error
|
||||
ExpireOldUserInvites(ctx context.Context, cmd *models.ExpireTempUsersCommand) error
|
||||
GetDBHealthQuery(ctx context.Context, query *models.GetDBHealthQuery) error
|
||||
SearchOrgs(ctx context.Context, query *models.SearchOrgsQuery) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user