Chore: Delete org model duplicates (#60940)
* Delete org model duplicates * Fix lint * Move OrgDetailsDTO to org pkg
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/org/orgtest"
|
||||
)
|
||||
|
||||
@@ -28,11 +28,11 @@ func TestDashboardsAsConfig(t *testing.T) {
|
||||
orgFake := orgtest.NewOrgServiceFake()
|
||||
|
||||
t.Run("Should fail if orgs don't exist in the database", func(t *testing.T) {
|
||||
orgFake.ExpectedError = models.ErrOrgNotFound
|
||||
orgFake.ExpectedError = org.ErrOrgNotFound
|
||||
cfgProvider := configReader{path: appliedDefaults, log: logger, orgService: orgFake}
|
||||
_, err := cfgProvider.readConfig(context.Background())
|
||||
require.Error(t, err)
|
||||
assert.True(t, errors.Is(err, models.ErrOrgNotFound))
|
||||
assert.True(t, errors.Is(err, org.ErrOrgNotFound))
|
||||
orgFake.ExpectedError = nil
|
||||
})
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
models "github.com/grafana/grafana/pkg/models"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
)
|
||||
|
||||
// Store is an autogenerated mock type for the Store type
|
||||
@@ -15,11 +16,11 @@ type Store struct {
|
||||
}
|
||||
|
||||
// GetOrgByNameHandler provides a mock function with given fields: ctx, query
|
||||
func (_m *Store) GetOrgByNameHandler(ctx context.Context, query *models.GetOrgByNameQuery) error {
|
||||
func (_m *Store) GetOrgByNameHandler(ctx context.Context, query * org.GetOrgByNameQuery) error {
|
||||
ret := _m.Called(ctx, query)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *models.GetOrgByNameQuery) error); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *org.GetOrgByNameQuery) error); ok {
|
||||
r0 = rf(ctx, query)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
|
||||
@@ -84,13 +84,6 @@ type mockStore struct {
|
||||
updateRequests []*pluginsettings.UpdateArgs
|
||||
}
|
||||
|
||||
func (m *mockStore) GetOrgByNameHandler(_ context.Context, query *models.GetOrgByNameQuery) error {
|
||||
if query.Name == "Org 4" {
|
||||
query.Result = &models.Org{Id: 4}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockStore) GetPluginSettingByPluginID(_ context.Context, args *pluginsettings.GetByPluginIDArgs) (*pluginsettings.DTO, error) {
|
||||
if args.PluginID == "test-plugin" && args.OrgID == 2 {
|
||||
return &pluginsettings.DTO{
|
||||
|
||||
@@ -14,10 +14,10 @@ type DashboardStore interface {
|
||||
}
|
||||
|
||||
func CheckOrgExists(ctx context.Context, orgService org.Service, orgID int64) error {
|
||||
query := org.GetOrgByIdQuery{ID: orgID}
|
||||
query := org.GetOrgByIDQuery{ID: orgID}
|
||||
_, err := orgService.GetByID(ctx, &query)
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrOrgNotFound) {
|
||||
if errors.Is(err, org.ErrOrgNotFound) {
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("failed to check whether org. with the given ID exists: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user