Skip to content

test: integration tests for partial_match substring rejection (#193)#238

Merged
Zious11 merged 1 commit intodevelopfrom
test/partial-match-integration-193
Apr 20, 2026
Merged

test: integration tests for partial_match substring rejection (#193)#238
Zious11 merged 1 commit intodevelopfrom
test/partial-match-integration-193

Conversation

@Zious11
Copy link
Copy Markdown
Owner

@Zious11 Zious11 commented Apr 20, 2026

Summary

How it works

Each test mocks the candidate-list GET and mounts the state-changing POST with .expect(0). wiremock fails the test if the short-circuit is ever bypassed. Inputs are chosen so partial_match resolves to exactly one candidate (e.g., "prog""In Progress"), exercising the Ambiguous-single-hit path rather than None or Ambiguous-multi-hit.

Findings from local review (addressed / deferred)

Test plan

  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets -- -D warnings clean
  • cargo test — 803 passed, 0 failed (baseline 782 + 21)
  • The 3 new tests isolated and passing:
    • test_move_single_substring_rejected_no_input
    • test_link_single_substring_rejected_no_input
    • issue_list_status_single_substring_rejected

Closes #193

Lock the handler-level guarantee that a single-hit substring under
--no-input routes through MatchResult::Ambiguous and errors before any
state-changing HTTP call at three call sites identified in #193:

  - issue move --to "prog"  (workflow.rs:129, exits 1 via bail!)
  - issue link --type "block"  (links.rs:62, exits 1 via bail!)
  - issue list --status "prog"  (list.rs:220, exits 64 via UserError)

Each test mocks the candidate GET and mounts the state-changing POST
with .expect(0) so wiremock fails the test if the short-circuit is
ever bypassed. Complements the matcher's own unit tests in
src/partial_match.rs; no production code changes.

Scope: the three call sites named in #193. Additional uncovered
callers (unlink, helpers team/user/asset, assets search/schema/tickets,
queue view) filed as #236. Exit-code inconsistency between bail!
(exit 1) and UserError (exit 64) filed as #237.

Closes #193
Copy link
Copy Markdown

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

Adds handler-level integration coverage to ensure single-hit substring inputs under --no-input are treated as ambiguous and fail before any downstream HTTP action, preventing regressions from the strict-matching rollout.

Changes:

  • Add an integration test for jr issue list --status <substring> --no-input asserting exit code 64 and no JQL search call.
  • Add integration tests for jr issue move <substring> --no-input and jr issue link --type <substring> --no-input asserting failure and no state-changing POST.
  • Pin current exit-code behavior for move/link (1) vs list (64) to make future normalization explicit.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/issue_list_errors.rs Adds issue list --status ambiguous-substring rejection test and asserts no /search/jql call occurs.
tests/issue_commands.rs Adds issue move and issue link ambiguous-substring rejection tests asserting no state-changing POST occurs.

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

@Zious11 Zious11 merged commit 1e89e57 into develop Apr 20, 2026
11 checks passed
@Zious11 Zious11 deleted the test/partial-match-integration-193 branch April 20, 2026 23:55
Zious11 added a commit that referenced this pull request Apr 21, 2026
issue move, issue link, and issue unlink reported ambiguous-substring
errors via anyhow::bail! which doesn't inject a JrError into the cause
chain, so main.rs fell back to exit 1. issue list --status already used
JrError::UserError (exit 64) for the same failure class, producing an
inconsistency that broke scripts keying off $? == 64.

Change the three Ambiguous + no_input branches to return
JrError::UserError so all four handlers surface exit 64 uniformly.
Error-message strings are byte-identical — no script-visible wording
changes. Updates the two tests added in PR #238 to pin Some(64).

Closes #237
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.

test: add integration tests for substring rejection across all partial_match callers

2 participants