Skip to content

test: substring-rejection tests for unlink, queue, assets schema (#236)#241

Merged
Zious11 merged 1 commit intodevelopfrom
test/partial-match-extended-236
Apr 21, 2026
Merged

test: substring-rejection tests for unlink, queue, assets schema (#236)#241
Zious11 merged 1 commit intodevelopfrom
test/partial-match-extended-236

Conversation

@Zious11
Copy link
Copy Markdown
Owner

@Zious11 Zious11 commented Apr 21, 2026

Summary

Extends handler-level partial_match single-substring rejection coverage to three more call sites from #236:

  • issue unlink (binary test) — jr unlink --type block → exit 64, Ambiguous link type, no DELETE fires
  • queue resolve (library test on resolve_queue_by_name) — complements existing ExactMultiple test; asserts JrError::UserError via downcast
  • assets schema --schema (binary test) — jr assets schema AnyType --schema its → exit 64, Ambiguous schema, no object-type listing fires

Each test uses a genuine single-hit substring (block, escal, its) against a candidate list where only one entry substring-matches, so the test exercises the #193 regression surface directly (single-hit substrings that used to resolve silently now route through Ambiguous).

Scope

This PR covers 3 of the 8 call sites listed in #236. The remaining 5 are deferred to #240:

Design choices

  • Queue test is library-level, not binary. The full binary path for jr queue view requires project-meta + service-desk discovery + queue list mocks (3 chained mocks). The test precedent at queue.rs:190 (resolve_queue_duplicate_names_error_message) is library-level; this PR mirrors that pattern for the Ambiguous variant.
  • Unlink test mounts no DELETE mock — wiremock 404s unmatched requests, which would surface as a different error if a delete were attempted. Combined with the exit 64 + Ambiguous link type assertions this implicitly locks the short-circuit.
  • Assets schema test uses .expect(0) on both objecttypes/flat endpoints — explicit short-circuit assertion.

Test plan

  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets -- -D warnings clean
  • cargo test — 806 passed, 0 failed (+3 new over baseline 803)
  • Local code review: no critical/important findings

Refs #236

#236)

Adds handler-level (or library-level where plumbing outweighs signal)
coverage for three more partial_match callers identified in #236:

  - issue unlink  (tests/issue_commands.rs — binary test, exit 64)
  - queue resolve (tests/queue.rs — library test on resolve_queue_by_name)
  - assets schema (tests/assets.rs — binary test, --schema ambiguity)

Each uses a single-hit substring input (per the #193 regression
surface) and asserts the Ambiguous branch fires with the expected
disambiguation message. The binary tests pin exit 64 to complement
PR #239's bail!→UserError unification. The unlink test mounts no
DELETE mock so wiremock 404s any state-change attempt; the assets
schema test mounts both objecttypes/flat endpoints with .expect(0)
to lock the short-circuit.

The remaining 5 call sites from #236 (helpers.rs team/user/asset,
assets search --status, assets schema <type_name>) need CMDB/user/
team plumbing or await a parallel bail!→UserError refactor of
helpers.rs. Tracked in #240.

Refs #236
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

Expands regression coverage for the partial_match strict-matching behavior (single-substring inputs now routed through Ambiguous) across additional CLI/library call sites to prevent silent resolution under --no-input.

Changes:

  • Add a library-level test ensuring queue name single-substring input yields JrError::UserError with the disambiguation message.
  • Add a binary integration test ensuring issue unlink --type <substring> fails with exit code 64 and short-circuits before any DELETE.
  • Add a binary integration test ensuring assets schema --schema <substring> fails with exit code 64 and short-circuits before any object-type listing.

Reviewed changes

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

File Description
tests/queue.rs Adds resolve_queue_by_name single-substring ambiguity test and asserts UserError + message content.
tests/issue_commands.rs Adds jr issue unlink single-substring rejection test asserting exit 64 and no state-changing HTTP calls.
tests/assets.rs Adds jr assets schema --schema single-substring rejection test asserting exit 64 and no object-type listing calls.

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

@Zious11 Zious11 merged commit 0d819cf into develop Apr 21, 2026
11 checks passed
@Zious11 Zious11 deleted the test/partial-match-extended-236 branch April 21, 2026 03:57
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