Chore: Remove dashboard version from models (#50287)
* Remove dashbpard version from models * Fix lint * Fix api & sqlstore tests * Remove integration tags * Fix lint again * Add integration test to correct namespace * Lont fix 2 * Change Id to ID in dashVersionMeta
This commit is contained in:
@@ -634,9 +634,9 @@ func (hs *HTTPServer) GetDashboardVersion(c *models.ReqContext) response.Respons
|
||||
creator = hs.getUserLogin(c.Req.Context(), res.CreatedBy)
|
||||
}
|
||||
|
||||
dashVersionMeta := &models.DashboardVersionMeta{
|
||||
Id: res.ID,
|
||||
DashboardId: res.DashboardID,
|
||||
dashVersionMeta := &dashver.DashboardVersionMeta{
|
||||
ID: res.ID,
|
||||
DashboardID: res.DashboardID,
|
||||
DashboardUID: dashUID,
|
||||
Data: res.Data,
|
||||
ParentVersion: res.ParentVersion,
|
||||
@@ -691,7 +691,7 @@ func (hs *HTTPServer) CalculateDashboardDiff(c *models.ReqContext) response.Resp
|
||||
|
||||
baseVersionRes, err := hs.dashboardVersionService.Get(c.Req.Context(), &baseVersionQuery)
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrDashboardVersionNotFound) {
|
||||
if errors.Is(err, dashver.ErrDashboardVersionNotFound) {
|
||||
return response.Error(404, "Dashboard version not found", err)
|
||||
}
|
||||
return response.Error(500, "Unable to compute diff", err)
|
||||
@@ -705,7 +705,7 @@ func (hs *HTTPServer) CalculateDashboardDiff(c *models.ReqContext) response.Resp
|
||||
|
||||
newVersionRes, err := hs.dashboardVersionService.Get(c.Req.Context(), &newVersionQuery)
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrDashboardVersionNotFound) {
|
||||
if errors.Is(err, dashver.ErrDashboardVersionNotFound) {
|
||||
return response.Error(404, "Dashboard version not found", err)
|
||||
}
|
||||
return response.Error(500, "Unable to compute diff", err)
|
||||
@@ -717,7 +717,7 @@ func (hs *HTTPServer) CalculateDashboardDiff(c *models.ReqContext) response.Resp
|
||||
result, err := dashdiffs.CalculateDiff(c.Req.Context(), &options, baseData, newData)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrDashboardVersionNotFound) {
|
||||
if errors.Is(err, dashver.ErrDashboardVersionNotFound) {
|
||||
return response.Error(404, "Dashboard version not found", err)
|
||||
}
|
||||
return response.Error(500, "Unable to compute diff", err)
|
||||
|
||||
@@ -722,20 +722,6 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Given two dashboards being compared", func(t *testing.T) {
|
||||
dashboardvs := []*models.DashboardVersion{
|
||||
{
|
||||
DashboardId: 1,
|
||||
Version: 1,
|
||||
Data: simplejson.NewFromAny(map[string]interface{}{
|
||||
"title": "Dash1",
|
||||
})},
|
||||
{
|
||||
DashboardId: 2,
|
||||
Version: 2,
|
||||
Data: simplejson.NewFromAny(map[string]interface{}{
|
||||
"title": "Dash2",
|
||||
})},
|
||||
}
|
||||
fakeDashboardVersionService := dashvertest.NewDashboardVersionServiceFake()
|
||||
fakeDashboardVersionService.ExpectedDashboardVersions = []*dashver.DashboardVersion{
|
||||
{
|
||||
@@ -753,7 +739,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
}),
|
||||
},
|
||||
}
|
||||
sqlmock := mockstore.SQLStoreMock{ExpectedDashboardVersions: dashboardvs}
|
||||
sqlmock := mockstore.SQLStoreMock{}
|
||||
setUp := func() {
|
||||
dashSvc := dashboards.NewFakeDashboardService(t)
|
||||
dashSvc.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Return(nil)
|
||||
@@ -861,12 +847,6 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
Version: 1,
|
||||
}
|
||||
mockSQLStore := mockstore.NewSQLStoreMock()
|
||||
mockSQLStore.ExpectedDashboardVersions = []*models.DashboardVersion{
|
||||
{
|
||||
DashboardId: 2,
|
||||
Version: 1,
|
||||
Data: fakeDash.Data,
|
||||
}}
|
||||
restoreDashboardVersionScenario(t, "When calling POST on", "/api/dashboards/id/1/restore",
|
||||
"/api/dashboards/id/:dashboardId/restore", dashboardService, fakeDashboardVersionService, cmd, func(sc *scenarioContext) {
|
||||
callRestoreDashboardVersion(sc)
|
||||
|
||||
@@ -2,7 +2,7 @@ package definitions
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
dashver "github.com/grafana/grafana/pkg/services/dashboardversion"
|
||||
)
|
||||
|
||||
// swagger:route GET /dashboards/id/{DashboardID}/versions dashboard_versions getDashboardVersions
|
||||
@@ -122,11 +122,11 @@ type GetDashboardVersionsParams struct {
|
||||
// swagger:response dashboardVersionsResponse
|
||||
type DashboardVersionsResponse struct {
|
||||
// in: body
|
||||
Body []*models.DashboardVersionDTO `json:"body"`
|
||||
Body []*dashver.DashboardVersionDTO `json:"body"`
|
||||
}
|
||||
|
||||
// swagger:response dashboardVersionResponse
|
||||
type DashboardVersionResponse struct {
|
||||
// in: body
|
||||
Body *models.DashboardVersionMeta `json:"body"`
|
||||
Body *dashver.DashboardVersionMeta `json:"body"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user