Summary
Add a focused unit-test seam for the cluster handler so tests can verify the Destroy() side effect: prepared-resource cleanup must not run when cluster uninstall fails and the cluster remains.
Rationale
The current helper-level tests in tests/utils/handler/cluster_handler_test.go verify the cleanup gate's boolean behavior, but they do not prove that clusterHandler.Destroy() avoids calling DestroyResources() when destroyCluster() reports clusterRemoved=false. The existing package has no suitable mocks/doubles for these collaborators, so this work was deferred from the fail-fast destroy change.
Affected areas
tests/utils/handler/cluster_handler.go
tests/utils/handler/cluster_handler_test.go
- Any minimal test-only seam, interface, or fake needed to control destroy and prepared-resource cleanup behavior
Required changes
- Introduce a minimal, idiomatic test seam that permits controlling the cluster-destroy result and observing prepared-resource cleanup.
- Add a focused Ginkgo/Gomega test that invokes
Destroy() with a simulated uninstall failure where clusterRemoved=false.
- Assert that
DestroyResources() is not invoked while the destroy error is still surfaced.
- Keep production behavior and the test harness scope minimal.
Acceptance criteria
- The test fails if
Destroy() calls prepared-resource cleanup after a failed/uncompleted uninstall.
- The test confirms the original destroy failure is preserved.
- Existing cleanup behavior remains covered when the cluster is removed.
Requested by: @amandahla
Related PR: #3433
Related review comment: #3433 (comment)
Summary
Add a focused unit-test seam for the cluster handler so tests can verify the
Destroy()side effect: prepared-resource cleanup must not run when cluster uninstall fails and the cluster remains.Rationale
The current helper-level tests in
tests/utils/handler/cluster_handler_test.goverify the cleanup gate's boolean behavior, but they do not prove thatclusterHandler.Destroy()avoids callingDestroyResources()whendestroyCluster()reportsclusterRemoved=false. The existing package has no suitable mocks/doubles for these collaborators, so this work was deferred from the fail-fast destroy change.Affected areas
tests/utils/handler/cluster_handler.gotests/utils/handler/cluster_handler_test.goRequired changes
Destroy()with a simulated uninstall failure whereclusterRemoved=false.DestroyResources()is not invoked while the destroy error is still surfaced.Acceptance criteria
Destroy()calls prepared-resource cleanup after a failed/uncompleted uninstall.Requested by: @amandahla
Related PR: #3433
Related review comment: #3433 (comment)