K8s: Fix legacy fallback provisioning (#100566)
This commit is contained in:
@@ -251,26 +251,51 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Should delete associated provisioning info, even without the dashboard existing in the db", func(t *testing.T) {
|
||||
setup()
|
||||
dash1 := insertTestDashboard(t, dashboardStore, "provisioned", 1, 0, "", false, "provisioned")
|
||||
dash2 := insertTestDashboard(t, dashboardStore, "orphaned", 1, 0, "", false, "orphaned")
|
||||
provisioningData := &dashboards.DashboardProvisioning{
|
||||
ID: 1,
|
||||
DashboardID: 200,
|
||||
DashboardID: dash1.ID,
|
||||
Name: "test",
|
||||
CheckSum: "123",
|
||||
Updated: 54321,
|
||||
ExternalID: "/path/to/dashboard",
|
||||
}
|
||||
err := dashboardStore.SaveProvisionedDashboard(context.Background(), &dashboards.Dashboard{
|
||||
ID: 200,
|
||||
}, provisioningData)
|
||||
err := dashboardStore.SaveProvisionedDashboard(context.Background(), dash1, provisioningData)
|
||||
require.NoError(t, err)
|
||||
provisioningData2 := &dashboards.DashboardProvisioning{
|
||||
ID: 1,
|
||||
DashboardID: dash2.ID,
|
||||
Name: "orphaned",
|
||||
CheckSum: "123",
|
||||
Updated: 54321,
|
||||
ExternalID: "/path/to/dashboard",
|
||||
}
|
||||
err = dashboardStore.SaveProvisionedDashboard(context.Background(), dash2, provisioningData2)
|
||||
require.NoError(t, err)
|
||||
|
||||
// get provisioning data
|
||||
res, err := dashboardStore.GetProvisionedDashboardData(context.Background(), "test")
|
||||
require.NoError(t, err)
|
||||
require.Len(t, res, 1)
|
||||
require.Equal(t, res[0], provisioningData)
|
||||
|
||||
// get dashboards within the provisioner
|
||||
dashs, err := dashboardStore.GetProvisionedDashboardsByName(context.Background(), "test")
|
||||
require.NoError(t, err)
|
||||
require.Len(t, dashs, 1)
|
||||
|
||||
// find dashboards not within that provisioner
|
||||
dashs, err = dashboardStore.GetOrphanedProvisionedDashboards(context.Background(), []string{"test"})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, dashs, 1)
|
||||
// if both are provided, nothing should be returned
|
||||
dashs, err = dashboardStore.GetOrphanedProvisionedDashboards(context.Background(), []string{"test", "orphaned"})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, dashs, 0)
|
||||
|
||||
err = dashboardStore.CleanupAfterDelete(context.Background(), &dashboards.DeleteDashboardCommand{
|
||||
ID: 200,
|
||||
ID: dash1.ID,
|
||||
OrgID: 1,
|
||||
UID: "test",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user