Chore: Remove CreateOrg from alerting and use orgStore instead (#59440)

This commit is contained in:
Serge Zaitsev
2022-11-29 09:59:03 +01:00
committed by GitHub
parent 933879a347
commit 57fbe264ea
4 changed files with 20 additions and 81 deletions
@@ -1,6 +1,7 @@
package alerting
import (
"context"
"encoding/json"
"fmt"
"io"
@@ -11,6 +12,8 @@ import (
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/org/orgimpl"
"github.com/grafana/grafana/pkg/services/quota/quotatest"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/tests/testinfra"
"github.com/stretchr/testify/assert"
@@ -28,6 +31,9 @@ func TestAlertmanagerConfigurationIsTransactional(t *testing.T) {
grafanaListedAddr, store := testinfra.StartGrafana(t, dir, path)
orgService, err := orgimpl.ProvideService(store, store.Cfg, quotatest.New(false, nil))
require.NoError(t, err)
// editor from main organisation requests configuration
alertConfigURL := fmt.Sprintf("http://editor:editor@%s/api/alertmanager/grafana/config/api/v1/alerts", grafanaListedAddr)
@@ -39,7 +45,9 @@ func TestAlertmanagerConfigurationIsTransactional(t *testing.T) {
})
// create another organisation
orgID := createOrg(t, store, "another org", userID)
newOrg, err := orgService.CreateWithMember(context.Background(), &org.CreateOrgCommand{Name: "another org", UserID: userID})
require.NoError(t, err)
orgID := newOrg.ID
// create user under different organisation
createUser(t, store, user.CreateUserCommand{