Skip to content

test(ls): cover alias recursive listing mode#75

Merged
overtrue merged 1 commit intomainfrom
codex/ls-recursive-alias-test-gap
Apr 2, 2026
Merged

test(ls): cover alias recursive listing mode#75
overtrue merged 1 commit intomainfrom
codex/ls-recursive-alias-test-gap

Conversation

@overtrue
Copy link
Copy Markdown
Contributor

Summary

A recent ls behavior change made rc ls <alias>/ --recursive traverse every bucket and list objects server-wide, but that alias-only recursive branch had no direct unit coverage. That left the command selection logic unguarded even though it changed user-visible behavior.

User Impact

If that branch regresses, ls alias/ -r can silently fall back to bucket listing instead of object listing. Users would still get successful output, but it would be the wrong mode and the regression would be easy to miss.

Root Cause

The branch that distinguishes alias-only bucket listing from alias-only recursive object listing lived inline inside execute, so the changed path was only indirectly exercised. Existing tests covered path parsing, but not the mode decision introduced by the recent -r behavior change.

Fix

This PR extracts the alias-only listing decision into a small alias_listing_mode helper and adds focused unit tests for the three relevant cases:

  • alias-only path with --recursive selects all-object listing
  • alias-only path without --recursive selects bucket listing
  • bucket-qualified paths bypass the alias-only branch entirely

The implementation behavior is unchanged; the refactor is only there to make the recent branch testable and keep the scope tight to the changed area.

Validation

I ran the required checks locally:

  • cargo fmt --all --check
  • cargo clippy --workspace -- -D warnings
  • cargo test --workspace

@overtrue overtrue marked this pull request as ready for review April 2, 2026 01:42
Copilot AI review requested due to automatic review settings April 2, 2026 01:42
@overtrue overtrue merged commit c8f7c85 into main Apr 2, 2026
17 checks passed
@overtrue overtrue deleted the codex/ls-recursive-alias-test-gap branch April 2, 2026 01:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds focused unit coverage for the rc ls <alias>/ --recursive mode-selection behavior by extracting the alias-only branching logic into a dedicated helper, ensuring the recent user-visible ls behavior change is guarded by tests.

Changes:

  • Refactors alias-only listing selection into a small alias_listing_mode helper.
  • Adds unit tests covering alias-only recursive vs non-recursive behavior and ensuring bucket-qualified paths bypass the alias-only branch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +399 to +405
fn alias_listing_mode(bucket: Option<&String>, recursive: bool) -> Option<AliasListingMode> {
if bucket.is_some() {
return None;
}

if recursive {
Some(AliasListingMode::AllObjects)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

alias_listing_mode takes Option<&String>, which unnecessarily couples the helper to String and forces callers to pass bucket.as_ref(). Consider taking Option<&str> instead (and call with bucket.as_deref()), since the function only needs to know whether a bucket is present and this matches other helpers in the CLI that accept &str/Option<&str>.

Copilot uses AI. Check for mistakes.
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.

2 participants