Skip to content

Cleanup: dedupe reconcile_tests.rs mock boilerplate, extract media_stack_controller.rs orphan-cleanup/Event helpers #549

Description

@phaedrus1992

Summary

Follow-up from the code-simplifier pass on sprint #544's PR. Two non-blocking cleanup items,
deferred to keep that PR scoped to bug fixes:

1. Test duplication in reconcile_tests.rs

test_media_stack_reconcile_orphan_cleanup_runs_before_apply duplicates ~120 lines of wiremock
setup from test_media_stack_reconcile_orphan_cleanup (same PATCH/GET/DELETE/status mocks, only
the stack/child names differ). Extract a shared mount_orphan_stack_mocks(&mock_server, ...)
helper, or fold the newer test's extra assertions into the original.

2. media_stack_controller.rs / controller.rs functions are well over the 100-line guideline

media_stack_controller::reconcile (~400 lines) and controller::reconcile (~700 lines) both
grew new self-contained blocks in sprint #544's PR:

  • Orphan cleanup (PVC-detach + cascading delete) in media_stack_controller.rs could be
    fn cleanup_orphaned_children(&sa_api, &pvc_api, &name, &desired_children, &existing) -> ....
  • The DeprecatedImageOverride Warning Event publish in controller.rs could be
    fn publish_deprecated_image_override(&recorder, &obj_ref, app_type) -> ....

Extracting both makes them independently unit-testable without the full wiremock reconcile
harness, and chips away at both functions' size (tracked more broadly by #233/#492 for
controller.rs's overall size).

Context

Not a correctness issue -- pure readability/testability cleanup, safe to batch into a future
sprint alongside other code-health work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions