Skip to content

Add renderOperation helper and migrate mkdir/restore dry-run#350

Merged
AndreyVMarkelov merged 2 commits into
masterfrom
feature/dry-run-render-operation
Jul 10, 2026
Merged

Add renderOperation helper and migrate mkdir/restore dry-run#350
AndreyVMarkelov merged 2 commits into
masterfrom
feature/dry-run-render-operation

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Second PR in the dry-run generalization series. Introduces renderOperation, a shared helper that renders a command's operation output — the text closure plus the standard JSON operation envelope — so dry-run branches stop duplicating the commandOutput(cmd).Render(..., newJSONCommandOperationOutput(cmd, ...)) glue.

Migrates the two simplest dry-run commands, mkdir and restore, onto it. These are single planned operations with no discovery or both-modes path, so they validate the helper before it touches more complex commands.

Changes

  • cmd/dry_run.go — add renderOperation(cmd, input, results, warnings, textFn).
  • cmd/mkdir.go — dry-run branch calls renderOperation.
  • cmd/restore.go — dry-run branch calls renderOperation.

Behavior

Unchanged. The text closure that was already passed to .Render is passed to renderOperation verbatim. The existing byte-exact dry-run snapshots (TestMkdirJSONDryRunOutputSnapshot, TestMkdirDryRunTextOutputSnapshot, restore's JSON dry-run test) and the cross-command contract tests all continue to pass.

Testing

  • go build ./... clean
  • go vet ./cmd/ clean
  • go test ./cmd/ green (-count=1)

Notes

Text stays a per-command closure by design — restore's Would restore <path> to revision <rev> and later put/revoke output cannot be modeled by a shared struct. renderOperation owns only the envelope. Later PRs migrate share-link create/update, rm + share-link revoke, cp/mv, and put onto the same helper.

AndreyVMarkelov and others added 2 commits July 9, 2026 18:01
Add cross-command dry-run contract tests
Introduce renderOperation, a shared helper that renders a command's
operation output (text closure plus the standard JSON operation
envelope) so dry-run branches no longer duplicate the
commandOutput/newJSONCommandOperationOutput glue.

Migrate the two simplest dry-run commands, mkdir and restore, onto it.
Output is unchanged; the existing byte-exact dry-run snapshots and the
cross-command contract tests both continue to pass.
Sign up for free to 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.

1 participant