ldap debug bus removal (#45014)

* ldap debug bus removal

* linter
This commit is contained in:
ying-jeanne
2022-02-09 18:45:31 +08:00
committed by GitHub
parent 089a111858
commit ef11e783f1
13 changed files with 99 additions and 139 deletions

View File

@@ -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
}

View File

@@ -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 != "" {

View File

@@ -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)

View File

@@ -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
}