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:
Serge Zaitsev
2024-04-24 10:38:40 +02:00
committed by GitHub
parent f6e472f879
commit 522a98c126
50 changed files with 325 additions and 344 deletions
+5 -6
View File
@@ -16,7 +16,6 @@ import (
"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/sqlstore"
"github.com/grafana/grafana/pkg/services/stats"
"github.com/grafana/grafana/pkg/services/supportbundles/supportbundlestest"
"github.com/grafana/grafana/pkg/services/user"
@@ -33,9 +32,9 @@ func TestIntegrationStatsDataAccess(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
db := sqlstore.InitTestDB(t)
db, cfg := db.InitTestDBWithCfg(t)
statsService := &sqlStatsService{db: db}
populateDB(t, db, db.Cfg)
populateDB(t, db, cfg)
t.Run("Get system stats should not results in error", func(t *testing.T) {
query := stats.GetSystemStatsQuery{}
@@ -50,7 +49,7 @@ func TestIntegrationStatsDataAccess(t *testing.T) {
assert.Equal(t, int64(0), result.APIKeys)
assert.Equal(t, int64(2), result.Correlations)
assert.NotNil(t, result.DatabaseCreatedTime)
assert.Equal(t, db.Dialect.DriverName(), result.DatabaseDriver)
assert.Equal(t, db.GetDialect().DriverName(), result.DatabaseDriver)
})
t.Run("Get system user count stats should not results in error", func(t *testing.T) {
@@ -155,8 +154,8 @@ func TestIntegration_GetAdminStats(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
db := sqlstore.InitTestDB(t)
statsService := ProvideService(&setting.Cfg{}, db)
db, cfg := db.InitTestDBWithCfg(t)
statsService := ProvideService(cfg, db)
query := stats.GetAdminStatsQuery{}
_, err := statsService.GetAdminStats(context.Background(), &query)