Skip to content

test(data delete): cover the destructive teardown path (execute + partial-fail exit 7) - #249

Merged
saadqbal merged 1 commit into
developfrom
test/data-delete-destructive
Jul 14, 2026
Merged

test(data delete): cover the destructive teardown path (execute + partial-fail exit 7)#249
saadqbal merged 1 commit into
developfrom
test/data-delete-destructive

Conversation

@LukasWodka

@LukasWodkaLukasWodka commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Third increment from the CLI test-coverage audit — the destructive data delete path, a P0 (runDataDelete was 22%; every existing test stopped at cluster discovery, so the actual teardown — a DROP TABLE + file removal that can't be undone — had no coverage).

Production changes (seams — zero behavior change)

Two fn-var test seams, mirroring the existing loadClusterFn / listDatasetsFn pattern (both default to the real function, so production is unchanged):

  1. resolveClusterTargetFn — lets a command test inject a fully-resolved target (fake clientset + release + PVC) instead of seeding the k8s objects discoverRelease / DiscoverSharedPVC look for. runDataDelete now calls it.
  2. teardownFn — over push.Teardown (the DROP TABLE + file removal). runDataDelete's execute step now calls it.

Test

TestRunDataDelete_Execute drives the command past discovery via the seams, then exercises the three teardown outcomes:

  • clean → exit 0 + a Deleted line;
  • table dropped, file removal fails → exit 7 + the recovery hint (… was dropped, but removing its files failed — the idempotent-DROP re-run guidance);
  • fails before the drop → exit 7 teardown failed.

The mixed-case "Churn" input in the partial-failure case also pins the case-insensitive resolveDeleteTarget match (backend#1027 — a mis-cased name used to DROP nothing and still exit 0).

Why a seam, not a k8s fixture

resolveClusterTarget's success needs discoverRelease + DiscoverSharedPVC to find seeded objects — fiddly, and it's the established seam pattern that unblocks every command that resolves a target. Testing resolveClusterTarget's own success tail (its 47%) with real k8s objects is a separate follow-up.

Not in this PR (follow-ups)

  • Routing runClusterInfo / runClusterDoctor / realProbeEnv through loadClusterFn, and the stageFn seam for runDataIngest's --overwrite path — plus their tests.
  • resolveClusterTarget's own success-tail coverage (needs the k8s-object fixture).

Test plan

  • make ci green (build, -race, gofmt, lint, schema). New + existing data delete tests pass.

🤖 Generated with Claude Code


Note

Low Risk
No production behavior change; seams default to existing functions and the diff is tests plus indirection wiring only.

Overview
Adds test-only fn-var seams so runDataDelete can be exercised past cluster discovery without a real kubeconfig or cluster: resolveClusterTargetFn (injected resolved target) and teardownFn (over push.Teardown). Production still uses the real implementations; only call sites in runDataDelete switch to the seam variables.

TestRunDataDelete_Execute drives the destructive execute step with --yes and mocked targets, covering success (exit 0 + Deleted), partial failure after DROP TABLE (exit 7 + recovery hint), and failure before the drop (exit 7 teardown failed). The partial-failure case uses mixed-case Churn to lock in case-insensitive target resolution before teardown.

Reviewed by Cursor Bugbot for commit 1b0e871. Bugbot is set up for automated code reviews on this repo. Configure here.

…tial-fail)
runDataDelete was 22% — every test stopped at cluster discovery, so the
actual DROP TABLE + file removal (unrecoverable) had no coverage. Add two
fn-var test seams (default to the real funcs, zero behavior change),
mirroring loadClusterFn/listDatasetsFn:
- resolveClusterTargetFn: inject a canned target (fake clientset + release
+ PVC) without seeding the k8s objects discoverRelease/DiscoverSharedPVC
look for.
- teardownFn: over push.Teardown.
TestRunDataDelete_Execute drives past discovery and exercises the three
teardown outcomes: clean -> exit 0; table dropped but file removal fails
-> exit 7 + recovery hint; fails before the drop -> exit 7 "teardown
failed". The mixed-case "Churn" input also pins the case-insensitive
resolveDeleteTarget match (backend#1027).
make ci green. Follow-ups: loadClusterFn routing for cluster-info/doctor/
home + stageFn for ingest --overwrite; resolveClusterTarget's own success
tail (needs a k8s-object fixture).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

bugbot run

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1b0e871. Configure here.

@LukasWodkaLukasWodka self-assigned this Jul 14, 2026

@saadqbalsaadqbal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 The three teardown outcomes line up exactly with runDataDelete's error handling, and pinning the case-insensitive resolveDeleteTarget match (backend#1027) via the Churn case is a nice touch. Seams default to the real fns, so no behavior change. Note: since this stack adds seams to data.go, expect a rebase as the siblings land.

@saadqbal
saadqbal merged commit 1012d7a into developJul 14, 2026
22 checks passed
@saadqbal
saadqbal deleted the test/data-delete-destructive branch July 14, 2026 08:49
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@LukasWodka@saadqbal