Revert "Fix tests"

This reverts commit b0c2f072a2.
This commit is contained in:
Alexander Zobnin
2024-09-11 14:41:45 +02:00
parent 6a9c4579ab
commit c65cc7f0e1
9 changed files with 14 additions and 34 deletions
+2 -2
View File
@@ -839,14 +839,14 @@ func getDashboardShouldReturn200WithConfig(t *testing.T, sc *scenarioContext, pr
if dashboardService == nil {
dashboardService, err = service.ProvideDashboardServiceImpl(
cfg, dashboardStore, folderStore, features, folderPermissions, dashboardPermissions,
ac, folderSvc, nil, actest.FakeService{},
ac, folderSvc, nil,
)
require.NoError(t, err)
}
dashboardProvisioningService, err := service.ProvideDashboardServiceImpl(
cfg, dashboardStore, folderStore, features, folderPermissions, dashboardPermissions,
ac, folderSvc, nil, actest.FakeService{},
ac, folderSvc, nil,
)
require.NoError(t, err)
+1 -2
View File
@@ -23,7 +23,6 @@ import (
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
acdb "github.com/grafana/grafana/pkg/services/accesscontrol/database"
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
"github.com/grafana/grafana/pkg/services/accesscontrol/permreg"
@@ -477,7 +476,7 @@ func setupServer(b testing.TB, sc benchScenario, features featuremgmt.FeatureTog
dashboardSvc, err := dashboardservice.ProvideDashboardServiceImpl(
sc.cfg, dashStore, folderStore,
features, folderPermissions, dashboardPermissions, ac,
folderServiceWithFlagOn, nil, actest.FakeService{},
folderServiceWithFlagOn, nil,
)
require.NoError(b, err)
@@ -875,7 +875,6 @@ func permissionScenario(t *testing.T, desc string, canSave bool, fn permissionSc
ac,
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(t, err)
guardian.InitAccessControlGuardian(cfg, ac, dashboardService)
@@ -941,7 +940,6 @@ func callSaveWithResult(t *testing.T, cmd dashboards.SaveDashboardCommand, sqlSt
actest.FakeAccessControl{},
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(t, err)
res, err := service.SaveDashboard(context.Background(), &dto, false)
@@ -966,7 +964,6 @@ func callSaveWithError(t *testing.T, cmd dashboards.SaveDashboardCommand, sqlSto
actest.FakeAccessControl{},
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(t, err)
_, err = service.SaveDashboard(context.Background(), &dto, false)
@@ -1010,7 +1007,6 @@ func saveTestDashboard(t *testing.T, title string, orgID int64, folderUID string
actest.FakeAccessControl{},
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(t, err)
res, err := service.SaveDashboard(context.Background(), &dto, false)
@@ -1061,7 +1057,6 @@ func saveTestFolder(t *testing.T, title string, orgID int64, sqlStore db.ReplDB)
actest.FakeAccessControl{},
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(t, err)
res, err := service.SaveDashboard(context.Background(), &dto, false)
@@ -11,7 +11,6 @@ import (
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
dashboardsnapshot "github.com/grafana/grafana/pkg/apis/dashboardsnapshot/v0alpha1"
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
"github.com/grafana/grafana/pkg/services/dashboards"
dashdb "github.com/grafana/grafana/pkg/services/dashboards/database"
@@ -99,10 +98,7 @@ func TestValidateDashboardExists(t *testing.T) {
secretsService := secretsManager.SetupTestService(t, database.ProvideSecretsStore(sqlStore))
dashboardStore, err := dashdb.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotatest.New(false, nil))
require.NoError(t, err)
dashSvc, err := dashsvc.ProvideDashboardServiceImpl(
cfg, dashboardStore, folderimpl.ProvideDashboardFolderStore(sqlStore), nil, nil, nil,
acmock.New(), foldertest.NewFakeService(), nil, actest.FakeService{},
)
dashSvc, err := dashsvc.ProvideDashboardServiceImpl(cfg, dashboardStore, folderimpl.ProvideDashboardFolderStore(sqlStore), nil, nil, nil, acmock.New(), foldertest.NewFakeService(), nil)
require.NoError(t, err)
s := ProvideService(dsStore, secretsService, dashSvc)
ctx := context.Background()
@@ -429,7 +429,6 @@ func TestIntegrationNestedFolderService(t *testing.T) {
b := bus.ProvideBus(tracing.InitializeTracerForTest())
ac := acimpl.ProvideAccessControl(featuremgmt.WithFeatures(), zanzana.NewNoopClient())
acService := actest.FakeService{}
serviceWithFlagOn := &Service{
log: slog.New(logtest.NewTestHandler(t)).With("logger", "test-folder-service"),
@@ -486,7 +485,7 @@ func TestIntegrationNestedFolderService(t *testing.T) {
CanEditValue: true,
})
dashSrv, err := dashboardservice.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, featuresFlagOn, folderPermissions, dashboardPermissions, ac, serviceWithFlagOn, nil, acService)
dashSrv, err := dashboardservice.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, featuresFlagOn, folderPermissions, dashboardPermissions, ac, serviceWithFlagOn, nil)
require.NoError(t, err)
alertStore, err := ngstore.ProvideDBStore(cfg, featuresFlagOn, db, serviceWithFlagOn, dashSrv, ac)
@@ -568,7 +567,7 @@ func TestIntegrationNestedFolderService(t *testing.T) {
})
dashSrv, err := dashboardservice.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, featuresFlagOff,
folderPermissions, dashboardPermissions, ac, serviceWithFlagOff, nil, acService)
folderPermissions, dashboardPermissions, ac, serviceWithFlagOff, nil)
require.NoError(t, err)
alertStore, err := ngstore.ProvideDBStore(cfg, featuresFlagOff, db, serviceWithFlagOff, dashSrv, ac)
@@ -713,7 +712,7 @@ func TestIntegrationNestedFolderService(t *testing.T) {
tc.service.dashboardStore = dashStore
tc.service.store = nestedFolderStore
dashSrv, err := dashboardservice.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, tc.featuresFlag, folderPermissions, dashboardPermissions, ac, tc.service, nil, acService)
dashSrv, err := dashboardservice.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, tc.featuresFlag, folderPermissions, dashboardPermissions, ac, tc.service, nil)
require.NoError(t, err)
alertStore, err := ngstore.ProvideDBStore(cfg, tc.featuresFlag, db, tc.service, dashSrv, ac)
require.NoError(t, err)
@@ -1494,7 +1493,6 @@ func TestIntegrationNestedFolderSharedWithMe(t *testing.T) {
actest.FakeAccessControl{},
serviceWithFlagOn,
nil,
actest.FakeService{},
)
require.NoError(t, err)
@@ -310,7 +310,6 @@ func createDashboard(t *testing.T, sqlStore db.ReplDB, user user.SignedInUser, d
features, folderPermissions, dashboardPermissions, ac,
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(t, err)
dashboard, err := service.SaveDashboard(context.Background(), dashItem, true)
@@ -395,7 +394,6 @@ func scenarioWithPanel(t *testing.T, desc string, fn func(t *testing.T, sc scena
features, folderPermissions, dashboardPermissions, ac,
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(t, svcErr)
guardian.InitAccessControlGuardian(cfg, ac, dashboardService)
@@ -456,7 +454,8 @@ func testScenario(t *testing.T, desc string, fn func(t *testing.T, sc scenarioCo
dashService, dashSvcErr := dashboardservice.ProvideDashboardServiceImpl(
cfg, dashboardStore, folderStore,
features, folderPermissions, dashboardPermissions, ac,
foldertest.NewFakeService(), nil, actest.FakeService{},
foldertest.NewFakeService(),
nil,
)
require.NoError(t, dashSvcErr)
guardian.InitAccessControlGuardian(cfg, ac, dashService)
@@ -7,9 +7,6 @@ import (
"time"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/apimachinery/identity"
"github.com/grafana/grafana/pkg/bus"
@@ -40,6 +37,8 @@ import (
"github.com/grafana/grafana/pkg/services/user/userimpl"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tests/testsuite"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)
const userInDbName = "user_in_db"
@@ -736,7 +735,6 @@ func createDashboard(t *testing.T, sqlStore db.ReplDB, user *user.SignedInUser,
featuremgmt.WithFeatures(), acmock.NewMockedPermissionsService(), dashPermissionService, ac,
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(t, err)
dashboard, err := service.SaveDashboard(context.Background(), dashItem, true)
@@ -831,7 +829,6 @@ func testScenario(t *testing.T, desc string, fn func(t *testing.T, sc scenarioCo
featuremgmt.WithFeatures(), acmock.NewMockedPermissionsService(), dashPermissionService, ac,
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(t, err)
guardian.InitAccessControlGuardian(setting.NewCfg(), ac, dashService)
@@ -10,7 +10,6 @@ import (
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/dashboards/database"
@@ -60,7 +59,6 @@ func SetupDashboardService(tb testing.TB, sqlStore db.ReplDB, fs *folderimpl.Das
features, folderPermissions, dashboardPermissions, ac,
foldertest.NewFakeService(),
nil,
actest.FakeService{},
)
require.NoError(tb, err)
@@ -10,20 +10,18 @@ import (
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/apimachinery/errutil"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/infra/localcache"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
"github.com/grafana/grafana/pkg/services/annotations/annotationstest"
"github.com/grafana/grafana/pkg/services/dashboards"
@@ -325,7 +323,7 @@ func TestIntegrationUnauthenticatedUserCanGetPubdashPanelQueryData(t *testing.T)
dashService, err := service.ProvideDashboardServiceImpl(
cfg, dashboardStoreService, folderStore,
featuremgmt.WithFeatures(), acmock.NewMockedPermissionsService(), dashPermissionService, ac,
foldertest.NewFakeService(), nil, actest.FakeService{},
foldertest.NewFakeService(), nil,
)
require.NoError(t, err)