Remove folderid service test (#80433)
* Remove FolderID from service tests * Add models * Add folderID pack to publicdashboard tests * Remove folderID from dashboard tests * Remove folderID from folders * Remove folderID from ngalert tests * Remove nolint comment * Add back some tests after rebase
This commit is contained in:
@@ -31,15 +31,15 @@ func TestImportDashboardService(t *testing.T) {
|
||||
importDashboardFunc: func(ctx context.Context, dto *dashboards.SaveDashboardDTO) (*dashboards.Dashboard, error) {
|
||||
importDashboardArg = dto
|
||||
return &dashboards.Dashboard{
|
||||
ID: 4,
|
||||
UID: dto.Dashboard.UID,
|
||||
Slug: dto.Dashboard.Slug,
|
||||
OrgID: 3,
|
||||
Version: dto.Dashboard.Version,
|
||||
PluginID: "prometheus",
|
||||
FolderID: dto.Dashboard.FolderID, // nolint:staticcheck
|
||||
Title: dto.Dashboard.Title,
|
||||
Data: dto.Dashboard.Data,
|
||||
ID: 4,
|
||||
UID: dto.Dashboard.UID,
|
||||
Slug: dto.Dashboard.Slug,
|
||||
OrgID: 3,
|
||||
Version: dto.Dashboard.Version,
|
||||
PluginID: "prometheus",
|
||||
FolderUID: dto.Dashboard.FolderUID,
|
||||
Title: dto.Dashboard.Title,
|
||||
Data: dto.Dashboard.Data,
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
@@ -58,7 +58,6 @@ func TestImportDashboardService(t *testing.T) {
|
||||
}
|
||||
folderService := &foldertest.FakeService{
|
||||
ExpectedFolder: &folder.Folder{
|
||||
ID: 5, // nolint:staticcheck
|
||||
UID: "123",
|
||||
},
|
||||
}
|
||||
@@ -76,8 +75,9 @@ func TestImportDashboardService(t *testing.T) {
|
||||
Inputs: []dashboardimport.ImportDashboardInput{
|
||||
{Name: "*", Type: "datasource", Value: "prom"},
|
||||
},
|
||||
User: &user.SignedInUser{UserID: 2, OrgRole: org.RoleAdmin, OrgID: 3},
|
||||
FolderId: 5, // nolint:staticcheck
|
||||
User: &user.SignedInUser{UserID: 2, OrgRole: org.RoleAdmin, OrgID: 3},
|
||||
// FolderId: 5,
|
||||
FolderUid: "123",
|
||||
}
|
||||
resp, err := s.ImportDashboard(context.Background(), req)
|
||||
require.NoError(t, err)
|
||||
@@ -91,8 +91,7 @@ func TestImportDashboardService(t *testing.T) {
|
||||
require.Equal(t, int64(3), importDashboardArg.OrgID)
|
||||
require.Equal(t, int64(2), userID)
|
||||
require.Equal(t, "prometheus", importDashboardArg.Dashboard.PluginID)
|
||||
// nolint:staticcheck
|
||||
require.Equal(t, int64(5), importDashboardArg.Dashboard.FolderID)
|
||||
require.Equal(t, "123", importDashboardArg.Dashboard.FolderUID)
|
||||
|
||||
panel := importDashboardArg.Dashboard.Data.Get("panels").GetIndex(0)
|
||||
require.Equal(t, "prom", panel.Get("datasource").MustString())
|
||||
@@ -107,22 +106,21 @@ func TestImportDashboardService(t *testing.T) {
|
||||
importDashboardFunc: func(ctx context.Context, dto *dashboards.SaveDashboardDTO) (*dashboards.Dashboard, error) {
|
||||
importDashboardArg = dto
|
||||
return &dashboards.Dashboard{
|
||||
ID: 4,
|
||||
UID: dto.Dashboard.UID,
|
||||
Slug: dto.Dashboard.Slug,
|
||||
OrgID: 3,
|
||||
Version: dto.Dashboard.Version,
|
||||
PluginID: "prometheus",
|
||||
FolderID: dto.Dashboard.FolderID, // nolint:staticcheck
|
||||
Title: dto.Dashboard.Title,
|
||||
Data: dto.Dashboard.Data,
|
||||
ID: 4,
|
||||
UID: dto.Dashboard.UID,
|
||||
Slug: dto.Dashboard.Slug,
|
||||
OrgID: 3,
|
||||
Version: dto.Dashboard.Version,
|
||||
PluginID: "prometheus",
|
||||
FolderUID: dto.Dashboard.FolderUID,
|
||||
Title: dto.Dashboard.Title,
|
||||
Data: dto.Dashboard.Data,
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
libraryPanelService := &libraryPanelServiceMock{}
|
||||
folderService := &foldertest.FakeService{
|
||||
ExpectedFolder: &folder.Folder{
|
||||
ID: 5, // nolint:staticcheck
|
||||
UID: "123",
|
||||
},
|
||||
}
|
||||
@@ -144,8 +142,8 @@ func TestImportDashboardService(t *testing.T) {
|
||||
Inputs: []dashboardimport.ImportDashboardInput{
|
||||
{Name: "*", Type: "datasource", Value: "prom"},
|
||||
},
|
||||
User: &user.SignedInUser{UserID: 2, OrgRole: org.RoleAdmin, OrgID: 3},
|
||||
FolderId: 5, // nolint:staticcheck
|
||||
User: &user.SignedInUser{UserID: 2, OrgRole: org.RoleAdmin, OrgID: 3},
|
||||
FolderUid: "123",
|
||||
}
|
||||
resp, err := s.ImportDashboard(context.Background(), req)
|
||||
require.NoError(t, err)
|
||||
@@ -159,8 +157,7 @@ func TestImportDashboardService(t *testing.T) {
|
||||
require.Equal(t, int64(3), importDashboardArg.OrgID)
|
||||
require.Equal(t, int64(2), userID)
|
||||
require.Equal(t, "", importDashboardArg.Dashboard.PluginID)
|
||||
// nolint:staticcheck
|
||||
require.Equal(t, int64(5), importDashboardArg.Dashboard.FolderID)
|
||||
require.Equal(t, "123", importDashboardArg.Dashboard.FolderUID)
|
||||
|
||||
panel := importDashboardArg.Dashboard.Data.Get("panels").GetIndex(0)
|
||||
require.Equal(t, "prom", panel.Get("datasource").MustString())
|
||||
|
||||
Reference in New Issue
Block a user