Chore: Make Cfg field private in SQLStore (#85593)
* make cfg private in sqlstore * fix db init in tests * fix case * fix folder test init * fix imports * make another Cfg private * remove another Cfg * remove unused variable * use store cfg, it has side-effects * fix mutated cfg in tests
This commit is contained in:
@@ -63,7 +63,7 @@ func TestIntegrationListPublicDashboard(t *testing.T) {
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t, db.InitTestDBOpt{})
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t, db.InitTestDBOpt{})
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
@@ -178,7 +178,7 @@ func TestIntegrationExistsEnabledByAccessToken(t *testing.T) {
|
||||
var savedDashboard *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t)
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
@@ -251,7 +251,7 @@ func TestIntegrationExistsEnabledByDashboardUid(t *testing.T) {
|
||||
var savedDashboard *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t)
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
@@ -316,7 +316,7 @@ func TestIntegrationFindByDashboardUid(t *testing.T) {
|
||||
var savedDashboard *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t)
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
@@ -385,7 +385,7 @@ func TestIntegrationFindByAccessToken(t *testing.T) {
|
||||
var err error
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t)
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotatest.New(false, nil))
|
||||
require.NoError(t, err)
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
@@ -453,7 +453,7 @@ func TestIntegrationCreatePublicDashboard(t *testing.T) {
|
||||
var savedDashboard2 *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t, db.InitTestDBOpt{})
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t, db.InitTestDBOpt{})
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
@@ -533,7 +533,7 @@ func TestIntegrationUpdatePublicDashboard(t *testing.T) {
|
||||
var err error
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t, db.InitTestDBOpt{})
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t, db.InitTestDBOpt{})
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
@@ -637,7 +637,7 @@ func TestIntegrationGetOrgIdByAccessToken(t *testing.T) {
|
||||
var err error
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t)
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
@@ -710,7 +710,7 @@ func TestIntegrationDelete(t *testing.T) {
|
||||
var err error
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t)
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotatest.New(false, nil))
|
||||
require.NoError(t, err)
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
@@ -742,9 +742,9 @@ func TestIntegrationDelete(t *testing.T) {
|
||||
|
||||
func TestFindByFolder(t *testing.T) {
|
||||
t.Run("returns nil when dashboard is not a folder", func(t *testing.T) {
|
||||
sqlStore, _ := db.InitTestDBwithCfg(t)
|
||||
sqlStore, cfg := db.InitTestDBWithCfg(t)
|
||||
dashboard := &dashboards.Dashboard{OrgID: 1, UID: "dashboarduid", IsFolder: false}
|
||||
store := ProvideStore(sqlStore, sqlStore.Cfg, featuremgmt.WithFeatures())
|
||||
store := ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
pubdashes, err := store.FindByFolder(context.Background(), dashboard.OrgID, dashboard.UID)
|
||||
|
||||
require.NoError(t, err)
|
||||
@@ -752,8 +752,8 @@ func TestFindByFolder(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("returns nil when parameters are empty", func(t *testing.T) {
|
||||
sqlStore, _ := db.InitTestDBwithCfg(t)
|
||||
store := ProvideStore(sqlStore, sqlStore.Cfg, featuremgmt.WithFeatures())
|
||||
sqlStore, cfg := db.InitTestDBWithCfg(t)
|
||||
store := ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
pubdashes, err := store.FindByFolder(context.Background(), 0, "")
|
||||
|
||||
require.NoError(t, err)
|
||||
@@ -761,11 +761,11 @@ func TestFindByFolder(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("can get all pubdashes for dashboard folder and org", func(t *testing.T) {
|
||||
sqlStore, _ := db.InitTestDBwithCfg(t)
|
||||
sqlStore, cfg := db.InitTestDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err := dashboardsDB.ProvideDashboardStore(sqlStore, sqlStore.Cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
dashboardStore, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
pubdashStore := ProvideStore(sqlStore, sqlStore.Cfg, featuremgmt.WithFeatures())
|
||||
pubdashStore := ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
// insert folders
|
||||
folder := insertTestDashboard(t, dashboardStore, "This is a folder", 1, "", true, PublicShareType)
|
||||
folder2 := insertTestDashboard(t, dashboardStore, "This is another folder", 1, "", true, PublicShareType)
|
||||
@@ -800,7 +800,7 @@ func TestGetMetrics(t *testing.T) {
|
||||
var savedDashboard4 *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBwithCfg(t, db.InitTestDBOpt{})
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t, db.InitTestDBOpt{})
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user