fix(tests): fix integration test failures for export resources
- Add validation for empty Resources list in ExportJobOptions - Add SkipResourceAssertions to tests that create resources before repo - Fix managed resources test to use folder target instead of instance - Tests create dashboards/folders before repository, so sync counts include them
This commit is contained in:
@@ -101,7 +101,11 @@ func validateExportJobOptions(opts *provisioning.ExportJobOptions) field.ErrorLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate resources if specified
|
// Validate resources if specified
|
||||||
if len(opts.Resources) > 0 {
|
// If Resources is provided, it must not be empty
|
||||||
|
if opts.Resources != nil {
|
||||||
|
if len(opts.Resources) == 0 {
|
||||||
|
list = append(list, field.Required(field.NewPath("spec", "push", "resources"), "resources list cannot be empty when specified"))
|
||||||
|
}
|
||||||
for i, r := range opts.Resources {
|
for i, r := range opts.Resources {
|
||||||
resourcePath := field.NewPath("spec", "push", "resources").Index(i)
|
resourcePath := field.NewPath("spec", "push", "resources").Index(i)
|
||||||
|
|
||||||
|
|||||||
@@ -47,10 +47,11 @@ func TestIntegrationProvisioning_ExportSpecificResources(t *testing.T) {
|
|||||||
// Create repository
|
// Create repository
|
||||||
const repo = "export-resources-test-repo"
|
const repo = "export-resources-test-repo"
|
||||||
testRepo := TestRepo{
|
testRepo := TestRepo{
|
||||||
Name: repo,
|
Name: repo,
|
||||||
Copies: map[string]string{},
|
Copies: map[string]string{},
|
||||||
ExpectedDashboards: 0, // No dashboards expected after sync (we'll export manually)
|
ExpectedDashboards: 0, // No dashboards expected after sync (we'll export manually)
|
||||||
ExpectedFolders: 0,
|
ExpectedFolders: 0,
|
||||||
|
SkipResourceAssertions: true, // Skip assertions since we created dashboards before repo
|
||||||
}
|
}
|
||||||
helper.CreateRepo(t, testRepo)
|
helper.CreateRepo(t, testRepo)
|
||||||
|
|
||||||
@@ -115,10 +116,11 @@ func TestIntegrationProvisioning_ExportSpecificResourcesWithPath(t *testing.T) {
|
|||||||
// Create repository
|
// Create repository
|
||||||
const repo = "export-resources-path-test-repo"
|
const repo = "export-resources-path-test-repo"
|
||||||
testRepo := TestRepo{
|
testRepo := TestRepo{
|
||||||
Name: repo,
|
Name: repo,
|
||||||
Copies: map[string]string{},
|
Copies: map[string]string{},
|
||||||
ExpectedDashboards: 0,
|
ExpectedDashboards: 0,
|
||||||
ExpectedFolders: 0,
|
ExpectedFolders: 0,
|
||||||
|
SkipResourceAssertions: true, // Skip assertions since we created dashboard before repo
|
||||||
}
|
}
|
||||||
helper.CreateRepo(t, testRepo)
|
helper.CreateRepo(t, testRepo)
|
||||||
|
|
||||||
@@ -176,10 +178,11 @@ func TestIntegrationProvisioning_ExportSpecificResourcesRejectsFolders(t *testin
|
|||||||
// Create repository
|
// Create repository
|
||||||
const repo = "export-reject-folders-test-repo"
|
const repo = "export-reject-folders-test-repo"
|
||||||
testRepo := TestRepo{
|
testRepo := TestRepo{
|
||||||
Name: repo,
|
Name: repo,
|
||||||
Copies: map[string]string{},
|
Copies: map[string]string{},
|
||||||
ExpectedDashboards: 0,
|
ExpectedDashboards: 0,
|
||||||
ExpectedFolders: 0,
|
ExpectedFolders: 0,
|
||||||
|
SkipResourceAssertions: true, // Skip assertions since we created folder before repo
|
||||||
}
|
}
|
||||||
helper.CreateRepo(t, testRepo)
|
helper.CreateRepo(t, testRepo)
|
||||||
|
|
||||||
@@ -241,13 +244,15 @@ func TestIntegrationProvisioning_ExportSpecificResourcesRejectsManagedResources(
|
|||||||
manager, found := managedDashboard.GetAnnotations()[utils.AnnoKeyManagerIdentity]
|
manager, found := managedDashboard.GetAnnotations()[utils.AnnoKeyManagerIdentity]
|
||||||
require.True(t, found && manager != "", "dashboard should be managed")
|
require.True(t, found && manager != "", "dashboard should be managed")
|
||||||
|
|
||||||
// Create another repository for export
|
// Create another repository for export (must be folder target since instance can only exist alone)
|
||||||
const exportRepo = "export-managed-reject-test-repo"
|
const exportRepo = "export-managed-reject-test-repo"
|
||||||
exportTestRepo := TestRepo{
|
exportTestRepo := TestRepo{
|
||||||
Name: exportRepo,
|
Name: exportRepo,
|
||||||
Copies: map[string]string{},
|
Target: "folder",
|
||||||
ExpectedDashboards: 0,
|
Copies: map[string]string{},
|
||||||
ExpectedFolders: 0,
|
ExpectedDashboards: 0,
|
||||||
|
ExpectedFolders: 0,
|
||||||
|
SkipResourceAssertions: true, // Skip assertions since we're testing export, not sync
|
||||||
}
|
}
|
||||||
helper.CreateRepo(t, exportTestRepo)
|
helper.CreateRepo(t, exportTestRepo)
|
||||||
|
|
||||||
@@ -333,10 +338,11 @@ func TestIntegrationProvisioning_ExportSpecificResourcesWithFolderStructure(t *t
|
|||||||
// Create repository
|
// Create repository
|
||||||
const repo = "export-folder-structure-test-repo"
|
const repo = "export-folder-structure-test-repo"
|
||||||
testRepo := TestRepo{
|
testRepo := TestRepo{
|
||||||
Name: repo,
|
Name: repo,
|
||||||
Copies: map[string]string{},
|
Copies: map[string]string{},
|
||||||
ExpectedDashboards: 0,
|
ExpectedDashboards: 0,
|
||||||
ExpectedFolders: 0,
|
ExpectedFolders: 0,
|
||||||
|
SkipResourceAssertions: true, // Skip assertions since we created folder and dashboard before repo
|
||||||
}
|
}
|
||||||
helper.CreateRepo(t, testRepo)
|
helper.CreateRepo(t, testRepo)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user