Chore: Remove CreateUserForTests() (#64125)
* Chore: Remove CreateUserForTests * Apply suggestion from code review
This commit is contained in:
@@ -2569,7 +2569,7 @@ func createUser(t *testing.T, store *sqlstore.SQLStore, cmd user.CreateUserComma
|
||||
usrSvc, err := userimpl.ProvideService(store, orgService, store.Cfg, nil, nil, quotaService, supportbundlestest.NewFakeBundleService())
|
||||
require.NoError(t, err)
|
||||
|
||||
u, err := usrSvc.CreateUserForTests(context.Background(), &cmd)
|
||||
u, err := usrSvc.Create(context.Background(), &cmd)
|
||||
require.NoError(t, err)
|
||||
return u.ID
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestIntegrationAzureMonitor(t *testing.T) {
|
||||
grafanaListeningAddr, testEnv := testinfra.StartGrafanaEnv(t, dir, path)
|
||||
ctx := context.Background()
|
||||
|
||||
testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
u := testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
DefaultOrgRole: string(org.RoleAdmin),
|
||||
Password: "admin",
|
||||
Login: "admin",
|
||||
@@ -65,7 +65,7 @@ func TestIntegrationAzureMonitor(t *testing.T) {
|
||||
|
||||
uid := "azuremonitor"
|
||||
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgID: 1,
|
||||
OrgID: u.OrgID,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "Azure Monitor",
|
||||
Type: datasources.DS_AZURE_MONITOR,
|
||||
|
||||
@@ -145,7 +145,7 @@ func (c TestContext) createUser(cmd user.CreateUserCommand) User {
|
||||
usrSvc, err := userimpl.ProvideService(store, orgService, store.Cfg, nil, nil, quotaService, supportbundlestest.NewFakeBundleService())
|
||||
require.NoError(c.t, err)
|
||||
|
||||
user, err := usrSvc.CreateUserForTests(context.Background(), &cmd)
|
||||
user, err := usrSvc.Create(context.Background(), &cmd)
|
||||
require.NoError(c.t, err)
|
||||
|
||||
return User{
|
||||
|
||||
@@ -114,7 +114,7 @@ func createUser(t *testing.T, store *sqlstore.SQLStore, cmd user.CreateUserComma
|
||||
usrSvc, err := userimpl.ProvideService(store, orgService, store.Cfg, nil, nil, quotaService, supportbundlestest.NewFakeBundleService())
|
||||
require.NoError(t, err)
|
||||
|
||||
u, err := usrSvc.CreateUserForTests(context.Background(), &cmd)
|
||||
u, err := usrSvc.Create(context.Background(), &cmd)
|
||||
require.NoError(t, err)
|
||||
return u.ID
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestIntegrationElasticsearch(t *testing.T) {
|
||||
grafanaListeningAddr, testEnv := testinfra.StartGrafanaEnv(t, dir, path)
|
||||
ctx := context.Background()
|
||||
|
||||
testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
u := testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
DefaultOrgRole: string(org.RoleAdmin),
|
||||
Password: "admin",
|
||||
Login: "admin",
|
||||
@@ -57,7 +57,7 @@ func TestIntegrationElasticsearch(t *testing.T) {
|
||||
|
||||
uid := "es"
|
||||
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgID: 1,
|
||||
OrgID: u.OrgID,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "Elasticsearch",
|
||||
Type: datasources.DS_ES,
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestIntegrationGraphite(t *testing.T) {
|
||||
grafanaListeningAddr, testEnv := testinfra.StartGrafanaEnv(t, dir, path)
|
||||
ctx := context.Background()
|
||||
|
||||
testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
u := testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
DefaultOrgRole: string(org.RoleAdmin),
|
||||
Password: "admin",
|
||||
Login: "admin",
|
||||
@@ -55,7 +55,7 @@ func TestIntegrationGraphite(t *testing.T) {
|
||||
|
||||
uid := "graphite"
|
||||
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgID: 1,
|
||||
OrgID: u.OrgID,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "graphite",
|
||||
Type: datasources.DS_GRAPHITE,
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestIntegrationInflux(t *testing.T) {
|
||||
grafanaListeningAddr, testEnv := testinfra.StartGrafanaEnv(t, dir, path)
|
||||
ctx := context.Background()
|
||||
|
||||
testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
u := testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
DefaultOrgRole: string(org.RoleAdmin),
|
||||
Password: "admin",
|
||||
Login: "admin",
|
||||
@@ -55,7 +55,7 @@ func TestIntegrationInflux(t *testing.T) {
|
||||
|
||||
uid := "influxdb"
|
||||
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgID: 1,
|
||||
OrgID: u.OrgID,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "InfluxDB",
|
||||
Type: datasources.DS_INFLUXDB,
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestIntegrationLoki(t *testing.T) {
|
||||
grafanaListeningAddr, testEnv := testinfra.StartGrafanaEnv(t, dir, path)
|
||||
ctx := context.Background()
|
||||
|
||||
testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
u := testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
DefaultOrgRole: string(org.RoleAdmin),
|
||||
Password: "admin",
|
||||
Login: "admin",
|
||||
@@ -55,7 +55,7 @@ func TestIntegrationLoki(t *testing.T) {
|
||||
|
||||
uid := "loki"
|
||||
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgID: 1,
|
||||
OrgID: u.OrgID,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "Loki",
|
||||
Type: datasources.DS_LOKI,
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestIntegrationOpenTSDB(t *testing.T) {
|
||||
grafanaListeningAddr, testEnv := testinfra.StartGrafanaEnv(t, dir, path)
|
||||
ctx := context.Background()
|
||||
|
||||
testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
u := testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
DefaultOrgRole: string(org.RoleAdmin),
|
||||
Password: "admin",
|
||||
Login: "admin",
|
||||
@@ -55,7 +55,7 @@ func TestIntegrationOpenTSDB(t *testing.T) {
|
||||
|
||||
uid := "influxdb"
|
||||
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgID: 1,
|
||||
OrgID: u.OrgID,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "opentsdb",
|
||||
Type: datasources.DS_OPENTSDB,
|
||||
|
||||
@@ -129,7 +129,7 @@ func createUser(t *testing.T, store *sqlstore.SQLStore, cmd user.CreateUserComma
|
||||
usrSvc, err := userimpl.ProvideService(store, orgService, store.Cfg, nil, nil, quotaService, supportbundlestest.NewFakeBundleService())
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = usrSvc.CreateUserForTests(context.Background(), &cmd)
|
||||
_, err = usrSvc.Create(context.Background(), &cmd)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ func newTestScenario(t *testing.T, name string, opts []testScenarioOption, callb
|
||||
tsCtx.testEnv = testEnv
|
||||
ctx := context.Background()
|
||||
|
||||
testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
u := testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
DefaultOrgRole: string(org.RoleAdmin),
|
||||
Password: "admin",
|
||||
Login: "admin",
|
||||
@@ -284,7 +284,7 @@ func newTestScenario(t *testing.T, name string, opts []testScenarioOption, callb
|
||||
|
||||
tsCtx.uid = "test-plugin"
|
||||
cmd := &datasources.AddDataSourceCommand{
|
||||
OrgID: 1,
|
||||
OrgID: u.OrgID,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "TestPlugin",
|
||||
Type: tsCtx.testPluginID,
|
||||
@@ -306,7 +306,7 @@ func newTestScenario(t *testing.T, name string, opts []testScenarioOption, callb
|
||||
require.NoError(t, err)
|
||||
|
||||
getDataSourceQuery := &datasources.GetDataSourceQuery{
|
||||
OrgID: 1,
|
||||
OrgID: u.OrgID,
|
||||
UID: tsCtx.uid,
|
||||
}
|
||||
dataSource, err := testEnv.Server.HTTPServer.DataSourcesService.GetDataSource(ctx, getDataSourceQuery)
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestIntegrationPrometheus(t *testing.T) {
|
||||
grafanaListeningAddr, testEnv := testinfra.StartGrafanaEnv(t, dir, path)
|
||||
ctx := context.Background()
|
||||
|
||||
testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
u := testinfra.CreateUser(t, testEnv.SQLStore, user.CreateUserCommand{
|
||||
DefaultOrgRole: string(org.RoleAdmin),
|
||||
Password: "admin",
|
||||
Login: "admin",
|
||||
@@ -56,7 +56,7 @@ func TestIntegrationPrometheus(t *testing.T) {
|
||||
|
||||
uid := "prometheus"
|
||||
_, err := testEnv.Server.HTTPServer.DataSourcesService.AddDataSource(ctx, &datasources.AddDataSourceCommand{
|
||||
OrgID: 1,
|
||||
OrgID: u.OrgID,
|
||||
Access: datasources.DS_ACCESS_PROXY,
|
||||
Name: "Prometheus",
|
||||
Type: datasources.DS_PROMETHEUS,
|
||||
|
||||
Reference in New Issue
Block a user