Split Create User (#50502)
* Split Create User * Use new create user and User from package user * Add service to wire * Making create user work * Replace user from user pkg * One more * Move Insert to orguser Service/Store * Remove unnecessary conversion * Cleaunp * Fix Get User and add fakes * Fixing get org id for user logic, adding fakes and other adjustments * Add some tests for ourguser service and store * Fix insert org logic * Add comment about deprecation * Fix after merge with main * Move orguser service/store to org service/store * Remove orguser from wire * Unimplement new Create user and use User from pkg user * Fix wire generation * Fix lint * Fix lint - use only User and CrateUserCommand from user pkg * Remove User and CreateUserCommand from models * Fix lint 2
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -64,9 +65,9 @@ func TestIntegrationStatsDataAccess(t *testing.T) {
|
||||
func populateDB(t *testing.T, sqlStore *SQLStore) {
|
||||
t.Helper()
|
||||
|
||||
users := make([]models.User, 3)
|
||||
users := make([]user.User, 3)
|
||||
for i := range users {
|
||||
cmd := models.CreateUserCommand{
|
||||
cmd := user.CreateUserCommand{
|
||||
Email: fmt.Sprintf("usertest%v@test.com", i),
|
||||
Name: fmt.Sprintf("user name %v", i),
|
||||
Login: fmt.Sprintf("user_test_%v_login", i),
|
||||
@@ -78,7 +79,7 @@ func populateDB(t *testing.T, sqlStore *SQLStore) {
|
||||
}
|
||||
|
||||
// get 1st user's organisation
|
||||
getOrgByIdQuery := &models.GetOrgByIdQuery{Id: users[0].OrgId}
|
||||
getOrgByIdQuery := &models.GetOrgByIdQuery{Id: users[0].OrgID}
|
||||
err := sqlStore.GetOrgById(context.Background(), getOrgByIdQuery)
|
||||
require.NoError(t, err)
|
||||
org := getOrgByIdQuery.Result
|
||||
@@ -86,7 +87,7 @@ func populateDB(t *testing.T, sqlStore *SQLStore) {
|
||||
// add 2nd user as editor
|
||||
cmd := &models.AddOrgUserCommand{
|
||||
OrgId: org.Id,
|
||||
UserId: users[1].Id,
|
||||
UserId: users[1].ID,
|
||||
Role: models.ROLE_EDITOR,
|
||||
}
|
||||
err = sqlStore.AddOrgUser(context.Background(), cmd)
|
||||
@@ -95,14 +96,14 @@ func populateDB(t *testing.T, sqlStore *SQLStore) {
|
||||
// add 3rd user as viewer
|
||||
cmd = &models.AddOrgUserCommand{
|
||||
OrgId: org.Id,
|
||||
UserId: users[2].Id,
|
||||
UserId: users[2].ID,
|
||||
Role: models.ROLE_VIEWER,
|
||||
}
|
||||
err = sqlStore.AddOrgUser(context.Background(), cmd)
|
||||
require.NoError(t, err)
|
||||
|
||||
// get 2nd user's organisation
|
||||
getOrgByIdQuery = &models.GetOrgByIdQuery{Id: users[1].OrgId}
|
||||
getOrgByIdQuery = &models.GetOrgByIdQuery{Id: users[1].OrgID}
|
||||
err = sqlStore.GetOrgById(context.Background(), getOrgByIdQuery)
|
||||
require.NoError(t, err)
|
||||
org = getOrgByIdQuery.Result
|
||||
@@ -110,7 +111,7 @@ func populateDB(t *testing.T, sqlStore *SQLStore) {
|
||||
// add 1st user as admin
|
||||
cmd = &models.AddOrgUserCommand{
|
||||
OrgId: org.Id,
|
||||
UserId: users[0].Id,
|
||||
UserId: users[0].ID,
|
||||
Role: models.ROLE_ADMIN,
|
||||
}
|
||||
err = sqlStore.AddOrgUser(context.Background(), cmd)
|
||||
@@ -118,7 +119,7 @@ func populateDB(t *testing.T, sqlStore *SQLStore) {
|
||||
|
||||
// update 1st user last seen at
|
||||
updateUserLastSeenAtCmd := &models.UpdateUserLastSeenAtCommand{
|
||||
UserId: users[0].Id,
|
||||
UserId: users[0].ID,
|
||||
}
|
||||
err = sqlStore.UpdateUserLastSeenAt(context.Background(), updateUserLastSeenAtCmd)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user