Skip to content

Migrate put dry-run to renderOperation and unit-test the helper#354

Merged
AndreyVMarkelov merged 1 commit into
masterfrom
feature/dry-run-put
Jul 10, 2026
Merged

Migrate put dry-run to renderOperation and unit-test the helper#354
AndreyVMarkelov merged 1 commit into
masterfrom
feature/dry-run-put

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Sixth and final migration PR in the dry-run generalization series. Routes renderPlannedPutResults through the shared renderOperation helper (#350), completing the migration — every dry-run command now goes through one envelope path. Also adds direct unit tests for renderOperation itself.

Changes

  • cmd/put.gorenderPlannedPutResults uses renderOperation. All three put dry-run entry points (single file, recursive, stdin) funnel through this one function, so the single edit covers them.
  • cmd/dry_run_test.go — direct unit tests for renderOperation (previously covered only transitively).

Why put is the interesting case

put's dry-run emits mixed line typesWould create directory … interleaved with Would upload a → b — and carries warnings (skipped symlinks). This is the case that motivated keeping text as a per-command closure rather than a struct. It maps cleanly onto renderOperation: the closure keeps the mixed-line loop, and the helper's warnings argument carries the symlink warnings.

New helper tests

  • TestRenderOperationTextUsesClosure — text mode writes the closure's output verbatim.
  • TestRenderOperationJSONRendersEnvelopeAndSkipsClosure — JSON mode renders the full envelope (ok/schema_version/command), results passthrough, and warnings passthrough, while not invoking the text closure. Verified to fail if the warnings argument is dropped.

Route renderPlannedPutResults through the shared renderOperation helper,
completing the dry-run migration. All three put dry-run entry points
(single file, recursive, stdin) funnel through this one function, so the
single edit covers them. The closure keeps put's mixed create-directory
and upload line rendering, and renderOperation's warnings argument
carries the skipped-symlink warnings.

Also add direct unit tests for renderOperation, previously covered only
transitively through the migrated commands: text mode writes the
closure's output verbatim, and JSON mode renders the operation envelope
with results and warnings passthrough while skipping the text closure.

Verified byte-for-byte against the pre-refactor binary on a live account
for file, recursive (mixed lines), stdin, and symlink-warning cases,
with no remote mutation.
@AndreyVMarkelov AndreyVMarkelov merged commit 57be9d7 into master Jul 10, 2026
13 checks passed
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