Chore: Remove folderID from dashboardIdentity tests (#79195)

This commit is contained in:
Kat Yang 2023-12-13 04:50:46 -05:00 committed by GitHub
parent 1efd21c08a
commit 43356e28e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

View File

@ -484,9 +484,10 @@ type provisioningMetadata struct {
}
type dashboardIdentity struct {
// Deprecated: use FolderUID instead
folderID int64
title string
// Deprecated: use folderUID instead
folderID int64
folderUID string
title string
}
func (d *dashboardIdentity) Exists() bool {

View File

@ -39,11 +39,10 @@ func TestDuplicatesValidator(t *testing.T) {
fakeService.On("SaveFolderForProvisionedDashboards", mock.Anything, mock.Anything).Return(&dashboards.Dashboard{}, nil).Times(6)
fakeService.On("GetProvisionedDashboardData", mock.Anything, mock.AnythingOfType("string")).Return([]*dashboards.DashboardProvisioning{}, nil).Times(4)
fakeService.On("SaveProvisionedDashboard", mock.Anything, mock.Anything, mock.Anything).Return(&dashboards.Dashboard{}, nil).Times(5)
folderID, _, err := r.getOrCreateFolder(context.Background(), cfg, fakeService, folderName)
_, folderUID, err := r.getOrCreateFolder(context.Background(), cfg, fakeService, folderName)
require.NoError(t, err)
// nolint:staticcheck
identity := dashboardIdentity{folderID: folderID, title: "Grafana"}
identity := dashboardIdentity{folderUID: folderUID, title: "Grafana"}
cfg1 := &config{
Name: "first", Type: "file", OrgID: 1, Folder: folderName,
@ -93,11 +92,10 @@ func TestDuplicatesValidator(t *testing.T) {
fakeStore := &fakeDashboardStore{}
r, err := NewDashboardFileReader(cfg, logger, nil, fakeStore)
require.NoError(t, err)
folderID, _, err := r.getOrCreateFolder(context.Background(), cfg, fakeService, folderName)
_, folderUID, err := r.getOrCreateFolder(context.Background(), cfg, fakeService, folderName)
require.NoError(t, err)
// nolint:staticcheck
identity := dashboardIdentity{folderID: folderID, title: "Grafana"}
identity := dashboardIdentity{folderUID: folderUID, title: "Grafana"}
cfg1 := &config{
Name: "first", Type: "file", OrgID: 1, Folder: folderName,
@ -196,11 +194,10 @@ func TestDuplicatesValidator(t *testing.T) {
r, err := NewDashboardFileReader(cfg, logger, nil, fakeStore)
require.NoError(t, err)
folderID, _, err := r.getOrCreateFolder(context.Background(), cfg, fakeService, cfg1.Folder)
_, folderUID, err := r.getOrCreateFolder(context.Background(), cfg, fakeService, cfg1.Folder)
require.NoError(t, err)
// nolint:staticcheck
identity := dashboardIdentity{folderID: folderID, title: "Grafana"}
identity := dashboardIdentity{folderUID: folderUID, title: "Grafana"}
require.Equal(t, uint8(2), duplicates[1].UIDs["Z-phNqGmz"].Sum)
uidUsageReaders := keysToSlice(duplicates[1].UIDs["Z-phNqGmz"].InvolvedReaders)
@ -214,11 +211,10 @@ func TestDuplicatesValidator(t *testing.T) {
r, err = NewDashboardFileReader(cfg3, logger, nil, fakeStore)
require.NoError(t, err)
folderID, _, err = r.getOrCreateFolder(context.Background(), cfg3, fakeService, cfg3.Folder)
_, folderUID, err = r.getOrCreateFolder(context.Background(), cfg3, fakeService, cfg3.Folder)
require.NoError(t, err)
// nolint:staticcheck
identity = dashboardIdentity{folderID: folderID, title: "Grafana"}
identity = dashboardIdentity{folderUID: folderUID, title: "Grafana"}
require.Equal(t, uint8(2), duplicates[2].UIDs["Z-phNqGmz"].Sum)
uidUsageReaders = keysToSlice(duplicates[2].UIDs["Z-phNqGmz"].InvolvedReaders)