Skip to content

Add a focused Destroy() test for skipped prepared-resource cleanup after uninstall failure #3434

Description

@coderabbitai

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

  1. Introduce a minimal, idiomatic test seam that permits controlling the cluster-destroy result and observing prepared-resource cleanup.
  2. Add a focused Ginkgo/Gomega test that invokes Destroy() with a simulated uninstall failure where clusterRemoved=false.
  3. Assert that DestroyResources() is not invoked while the destroy error is still surfaced.
  4. 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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions