mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 06:22:35 +08:00
Chore: Replace sqlstore with db interface (#85366)
* replace sqlstore with db interface in a few packages * remove from stats * remove sqlstore in admin test * remove sqlstore from api plugin tests * fix another createUser * remove sqlstore in publicdashboards * remove sqlstore from orgs * clean up orguser test * more clean up in sso * clean up service accounts * further cleanup * more cleanup in accesscontrol * last cleanup in accesscontrol * clean up teams * more removals * split cfg from db in testenv * few remaining fixes * fix test with bus * pass cfg for testing inside db as an option * set query retries when no opts provided * revert golden test data * rebase and rollback
This commit is contained in:
@ -13,11 +13,13 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
"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/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
@ -32,7 +34,7 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
db := sqlstore.InitTestDB(t)
|
||||
folderStore := ProvideStore(db, db.Cfg)
|
||||
|
||||
orgID := CreateOrg(t, db)
|
||||
orgID := CreateOrg(t, db, db.Cfg)
|
||||
|
||||
t.Run("creating a folder without providing a UID should fail", func(t *testing.T) {
|
||||
_, err := folderStore.Create(context.Background(), folder.CreateFolderCommand{
|
||||
@ -152,7 +154,7 @@ func TestIntegrationDelete(t *testing.T) {
|
||||
db := sqlstore.InitTestDB(t)
|
||||
folderStore := ProvideStore(db, db.Cfg)
|
||||
|
||||
orgID := CreateOrg(t, db)
|
||||
orgID := CreateOrg(t, db, db.Cfg)
|
||||
|
||||
/*
|
||||
t.Run("attempt to delete unknown folder should fail", func(t *testing.T) {
|
||||
@ -199,7 +201,7 @@ func TestIntegrationUpdate(t *testing.T) {
|
||||
db := sqlstore.InitTestDB(t)
|
||||
folderStore := ProvideStore(db, db.Cfg)
|
||||
|
||||
orgID := CreateOrg(t, db)
|
||||
orgID := CreateOrg(t, db, db.Cfg)
|
||||
|
||||
// create parent folder
|
||||
parent, err := folderStore.Create(context.Background(), folder.CreateFolderCommand{
|
||||
@ -374,7 +376,7 @@ func TestIntegrationGet(t *testing.T) {
|
||||
db := sqlstore.InitTestDB(t)
|
||||
folderStore := ProvideStore(db, db.Cfg)
|
||||
|
||||
orgID := CreateOrg(t, db)
|
||||
orgID := CreateOrg(t, db, db.Cfg)
|
||||
|
||||
// create folder
|
||||
uid1 := util.GenerateShortUID()
|
||||
@ -491,7 +493,7 @@ func TestIntegrationGetParents(t *testing.T) {
|
||||
db := sqlstore.InitTestDB(t)
|
||||
folderStore := ProvideStore(db, db.Cfg)
|
||||
|
||||
orgID := CreateOrg(t, db)
|
||||
orgID := CreateOrg(t, db, db.Cfg)
|
||||
|
||||
// create folder
|
||||
uid1 := util.GenerateShortUID()
|
||||
@ -559,7 +561,7 @@ func TestIntegrationGetChildren(t *testing.T) {
|
||||
db := sqlstore.InitTestDB(t)
|
||||
folderStore := ProvideStore(db, db.Cfg)
|
||||
|
||||
orgID := CreateOrg(t, db)
|
||||
orgID := CreateOrg(t, db, db.Cfg)
|
||||
|
||||
// create folder
|
||||
uid1 := util.GenerateShortUID()
|
||||
@ -739,7 +741,7 @@ func TestIntegrationGetHeight(t *testing.T) {
|
||||
db := sqlstore.InitTestDB(t)
|
||||
folderStore := ProvideStore(db, db.Cfg)
|
||||
|
||||
orgID := CreateOrg(t, db)
|
||||
orgID := CreateOrg(t, db, db.Cfg)
|
||||
|
||||
// create folder
|
||||
uid1 := util.GenerateShortUID()
|
||||
@ -772,7 +774,7 @@ func TestIntegrationGetFolders(t *testing.T) {
|
||||
db := sqlstore.InitTestDB(t)
|
||||
folderStore := ProvideStore(db, db.Cfg)
|
||||
|
||||
orgID := CreateOrg(t, db)
|
||||
orgID := CreateOrg(t, db, db.Cfg)
|
||||
|
||||
// create folders
|
||||
uids := make([]string, 0)
|
||||
@ -886,10 +888,10 @@ func TestIntegrationGetFolders(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func CreateOrg(t *testing.T, db *sqlstore.SQLStore) int64 {
|
||||
func CreateOrg(t *testing.T, db db.DB, cfg *setting.Cfg) int64 {
|
||||
t.Helper()
|
||||
|
||||
orgService, err := orgimpl.ProvideService(db, db.Cfg, quotatest.New(false, nil))
|
||||
orgService, err := orgimpl.ProvideService(db, cfg, quotatest.New(false, nil))
|
||||
require.NoError(t, err)
|
||||
orgID, err := orgService.GetOrCreate(context.Background(), "test-org")
|
||||
require.NoError(t, err)
|
||||
|
Reference in New Issue
Block a user