Chore: Use dashboard service to retrieve dashboards (#79020)
This commit is contained in:
@@ -91,28 +91,6 @@ func (d *PublicDashboardStoreImpl) FindAllWithPagination(ctx context.Context, qu
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// FindDashboard returns a dashboard by orgId and dashboardUid
|
||||
func (d *PublicDashboardStoreImpl) FindDashboard(ctx context.Context, orgId int64, dashboardUid string) (*dashboards.Dashboard, error) {
|
||||
dashboard := &dashboards.Dashboard{OrgID: orgId, UID: dashboardUid}
|
||||
|
||||
var found bool
|
||||
err := d.sqlStore.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
var err error
|
||||
found, err = sess.Get(dashboard)
|
||||
return err
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !found {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return dashboard, nil
|
||||
}
|
||||
|
||||
// Find Returns public dashboard by Uid or nil if not found
|
||||
func (d *PublicDashboardStoreImpl) Find(ctx context.Context, uid string) (*PublicDashboard, error) {
|
||||
if uid == "" {
|
||||
|
||||
@@ -162,36 +162,6 @@ func TestIntegrationListPublicDashboard(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestIntegrationFindDashboard(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
var savedDashboard *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
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)
|
||||
dashboardStore = store
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, 0, "", true)
|
||||
}
|
||||
|
||||
t.Run("FindDashboard can get original dashboard by uid", func(t *testing.T) {
|
||||
setup()
|
||||
|
||||
dashboard, err := publicdashboardStore.FindDashboard(context.Background(), savedDashboard.OrgID, savedDashboard.UID)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, savedDashboard.UID, dashboard.UID)
|
||||
})
|
||||
}
|
||||
|
||||
func TestIntegrationExistsEnabledByAccessToken(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
|
||||
Reference in New Issue
Block a user