Chore: Remove DeleteUser from sqlstore (#59180)

* Remove DeleteUser from sqlstore

* Use Delete instead of DeleteUser

* Remove unused method
This commit is contained in:
idafurjes 2022-11-23 11:15:48 +01:00 committed by GitHub
parent 8761a71da2
commit 054d87e52e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 35 deletions

View File

@ -394,12 +394,6 @@ func getTeamSelectSQLBase(filteredUsers []string) string {
` FROM team as team `
}
func (ss *SQLStore) DeleteUser(ctx context.Context, cmd *models.DeleteUserCommand) error {
return ss.WithTransactionalDbSession(ctx, func(sess *DBSession) error {
return deleteUserInTransaction(ss, sess, cmd)
})
}
func (ss *SQLStore) DeleteUserInSession(ctx context.Context, sess *DBSession, cmd *models.DeleteUserCommand) error {
return deleteUserInTransaction(ss, sess, cmd)
}

View File

@ -420,15 +420,9 @@ func TestIntegrationUserDataAccess(t *testing.T) {
require.Nil(t, err)
// When the user is deleted
err = ss.DeleteUser(context.Background(), &models.DeleteUserCommand{UserId: users[1].ID})
err = userStore.Delete(context.Background(), users[1].ID)
require.Nil(t, err)
query1 := &org.GetOrgUsersQuery{OrgID: users[0].OrgID, User: usr}
query1Result, err := userStore.getOrgUsersForTest(context.Background(), query1)
require.Nil(t, err)
require.Len(t, query1Result, 1)
permQuery := &models.GetDashboardACLInfoListQuery{DashboardID: 1, OrgID: users[0].OrgID}
err = userStore.getDashboardACLInfoList(permQuery)
require.Nil(t, err)
@ -492,16 +486,9 @@ func TestIntegrationUserDataAccess(t *testing.T) {
require.EqualValues(t, query5Result.TotalCount, 5)
// the user is deleted
err = ss.DeleteUser(context.Background(), &models.DeleteUserCommand{UserId: users[1].ID})
err = userStore.Delete(context.Background(), users[1].ID)
require.Nil(t, err)
// delete connected org users and permissions
query2 := &org.GetOrgUsersQuery{OrgID: users[0].OrgID}
query2Result, err := userStore.getOrgUsersForTest(context.Background(), query2)
require.Nil(t, err)
require.Len(t, query2Result, 1)
permQuery = &models.GetDashboardACLInfoListQuery{DashboardID: 1, OrgID: users[0].OrgID}
err = userStore.getDashboardACLInfoList(permQuery)
require.Nil(t, err)
@ -850,20 +837,6 @@ func updateDashboardACL(t *testing.T, sqlStore db.DB, dashboardID int64, items .
return err
}
func (ss *sqlStore) getOrgUsersForTest(ctx context.Context, query *org.GetOrgUsersQuery) ([]*org.OrgUserDTO, error) {
result := make([]*org.OrgUserDTO, 0)
err := ss.db.WithDbSession(ctx, func(dbSess *db.Session) error {
sess := dbSess.Table("org_user")
sess.Join("LEFT ", ss.dialect.Quote("user"), fmt.Sprintf("org_user.user_id=%s.id", ss.dialect.Quote("user")))
sess.Where("org_user.org_id=?", query.OrgID)
sess.Cols("org_user.org_id", "org_user.user_id", "user.email", "user.login", "org_user.role")
err := sess.Find(&result)
return err
})
return result, err
}
// This function was copied from pkg/services/dashboards/database to circumvent
// import cycles. When this org-related code is refactored into a service the
// tests can the real GetDashboardACLInfoList functions