mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 02:32:19 +08:00
Remove deprecated FolderID from api tests (#79466)
* Remove deprecated FolderID from api tests * Removed unused const
This commit is contained in:
@ -377,14 +377,12 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
t.Run("Given two dashboards with the same title in different folders", func(t *testing.T) {
|
||||
dashOne := dashboards.NewDashboard("dash")
|
||||
dashOne.ID = 2
|
||||
// nolint:staticcheck
|
||||
dashOne.FolderID = 1
|
||||
dashOne.FolderUID = "folderUID"
|
||||
dashOne.HasACL = false
|
||||
|
||||
dashTwo := dashboards.NewDashboard("dash")
|
||||
dashTwo.ID = 4
|
||||
// nolint:staticcheck
|
||||
dashTwo.FolderID = 3
|
||||
dashTwo.FolderUID = "folderUID2"
|
||||
dashTwo.HasACL = false
|
||||
})
|
||||
|
||||
@ -393,7 +391,6 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
defer dashboardStore.AssertExpectations(t)
|
||||
// This tests that a valid request returns correct response
|
||||
t.Run("Given a correct request for creating a dashboard", func(t *testing.T) {
|
||||
const folderID int64 = 3
|
||||
folderUID := "Folder"
|
||||
const dashID int64 = 2
|
||||
|
||||
@ -404,19 +401,16 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
"title": "Dash",
|
||||
}),
|
||||
Overwrite: true,
|
||||
FolderID: folderID, // nolint:staticcheck
|
||||
FolderUID: folderUID,
|
||||
IsFolder: false,
|
||||
Message: "msg",
|
||||
}
|
||||
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
// nolint:staticcheck
|
||||
dashboardService.On("SaveDashboard", mock.Anything, mock.AnythingOfType("*dashboards.SaveDashboardDTO"), mock.AnythingOfType("bool")).
|
||||
Return(&dashboards.Dashboard{ID: dashID, UID: "uid", Title: "Dash", Slug: "dash", Version: 2, FolderUID: folderUID, FolderID: folderID}, nil)
|
||||
// nolint:staticcheck
|
||||
Return(&dashboards.Dashboard{ID: dashID, UID: "uid", Title: "Dash", Slug: "dash", Version: 2, FolderUID: folderUID}, nil)
|
||||
mockFolderService := &foldertest.FakeService{
|
||||
ExpectedFolder: &folder.Folder{ID: 1, UID: folderUID, Title: "Folder"},
|
||||
ExpectedFolder: &folder.Folder{UID: folderUID, Title: "Folder"},
|
||||
}
|
||||
|
||||
postDashboardScenario(t, "When calling POST on", "/api/dashboards", "/api/dashboards", cmd, dashboardService, mockFolderService, func(sc *scenarioContext) {
|
||||
@ -451,9 +445,8 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
dashboardService.On("SaveDashboard", mock.Anything, mock.AnythingOfType("*dashboards.SaveDashboardDTO"), mock.AnythingOfType("bool")).
|
||||
Return(&dashboards.Dashboard{ID: dashID, UID: "uid", Title: "Dash", Slug: "dash", Version: 2}, nil)
|
||||
|
||||
// nolint:staticcheck
|
||||
mockFolder := &foldertest.FakeService{
|
||||
ExpectedFolder: &folder.Folder{ID: 1, UID: "folderUID", Title: "Folder"},
|
||||
ExpectedFolder: &folder.Folder{UID: "folderUID", Title: "Folder"},
|
||||
}
|
||||
|
||||
postDashboardScenario(t, "When calling POST on", "/api/dashboards", "/api/dashboards", cmd, dashboardService, mockFolder, func(sc *scenarioContext) {
|
||||
@ -567,11 +560,8 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Given dashboard in folder being restored should restore to folder", func(t *testing.T) {
|
||||
const folderID int64 = 1
|
||||
fakeDash := dashboards.NewDashboard("Child dash")
|
||||
fakeDash.ID = 2
|
||||
// nolint:staticcheck
|
||||
fakeDash.FolderID = folderID
|
||||
fakeDash.HasACL = false
|
||||
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
@ -703,9 +693,6 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
|
||||
func TestDashboardVersionsAPIEndpoint(t *testing.T) {
|
||||
fakeDash := dashboards.NewDashboard("Child dash")
|
||||
fakeDash.ID = 1
|
||||
// nolint:staticcheck
|
||||
fakeDash.FolderID = 1
|
||||
|
||||
fakeDashboardVersionService := dashvertest.NewDashboardVersionServiceFake()
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
|
Reference in New Issue
Block a user