Skip to content

test(cli): cover cp local json error#133

Draft
overtrue wants to merge 1 commit intomainfrom
codex/cp-local-json-error-gap
Draft

test(cli): cover cp local json error#133
overtrue wants to merge 1 commit intomainfrom
codex/cp-local-json-error-gap

Conversation

@overtrue
Copy link
Copy Markdown
Contributor

Related issue

Automated test-gap detection for recent CLI structured-error changes.

Background and user impact

The cp command now emits structured JSON usage errors for local validation failures. The local-to-local copy path does not need S3, so it is a good candidate for a small regression test that proves users get machine-readable error metadata when they request JSON output.

Root cause

Existing tests covered cp parsing helpers and output serialization, but did not exercise the CLI binary path where two local filesystem paths are rejected under --json. That left the stderr JSON shape, exit code, error type, retryability flag, and custom suggestion unverified.

Solution

Added a focused error contract test that creates two temporary local files, runs rc cp source target --json, and asserts the command exits with usage code 2 while emitting the expected structured JSON error on stderr and no stdout.

Validation

  • make pre-commit was requested but unavailable because this checkout has no Makefile or pre-commit target.
  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • cargo test -p rustfs-cli --test error_contract cp_local_to_local_json_error_reports_usage_metadata

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