clean up duplicated user creation code (#50178)

* clean up duplicated user creation code

* remove unused duplicate getOrCreateOrg function

* fix up tests
This commit is contained in:
Dan Cech
2022-06-07 09:49:18 -04:00
committed by GitHub
parent 32a8af59d6
commit 9350ab781c
12 changed files with 46 additions and 213 deletions
@@ -18,7 +18,6 @@ import (
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
"github.com/grafana/grafana/pkg/services/star"
"github.com/grafana/grafana/pkg/services/star/starimpl"
"github.com/grafana/grafana/pkg/setting"
)
func TestIntegrationDashboardDataAccess(t *testing.T) {
@@ -657,9 +656,9 @@ func insertTestRule(t *testing.T, sqlStore *sqlstore.SQLStore, foderOrgID int64,
func CreateUser(t *testing.T, sqlStore *sqlstore.SQLStore, name string, role string, isAdmin bool) models.User {
t.Helper()
setting.AutoAssignOrg = true
setting.AutoAssignOrgId = 1
setting.AutoAssignOrgRole = role
sqlStore.Cfg.AutoAssignOrg = true
sqlStore.Cfg.AutoAssignOrgId = 1
sqlStore.Cfg.AutoAssignOrgRole = role
currentUserCmd := models.CreateUserCommand{Login: name, Email: name + "@test.com", Name: "a " + name, IsAdmin: isAdmin}
currentUser, err := sqlStore.CreateUser(context.Background(), currentUserCmd)
require.NoError(t, err)