Provisioning: validate files we read (#103197)

This commit is contained in:
Ryan McKinley
2025-04-01 17:49:08 +03:00
committed by GitHub
parent bfc6e07140
commit f087d5f61b
2 changed files with 15 additions and 5 deletions
@@ -260,10 +260,19 @@ func TestIntegrationProvisioning_ImportAllPanelsFromLocalRepository(t *testing.T
_, err := helper.Repositories.Resource.Create(ctx, localTmp, metav1.CreateOptions{})
require.NoError(t, err)
// Make sure the repo can see the file
_, err = helper.Repositories.Resource.Get(ctx, repo, metav1.GetOptions{}, "files", "all-panels.json")
// Make sure the repo can read and validate the file
obj, err := helper.Repositories.Resource.Get(ctx, repo, metav1.GetOptions{}, "files", "all-panels.json")
require.NoError(t, err, "valid path should be fine")
resource, _, err := unstructured.NestedMap(obj.Object, "resource")
require.NoError(t, err, "missing resource")
action, _, err := unstructured.NestedString(resource, "action")
require.NoError(t, err, "invalid action")
require.NotNil(t, resource["file"], "the raw file")
require.NotNil(t, resource["dryRun"], "dryRun result")
require.Equal(t, "create", action)
// But the dashboard shouldn't exist yet
const allPanels = "n1jR8vnnz"
_, err = helper.Dashboards.Resource.Get(ctx, allPanels, metav1.GetOptions{})