test: substring-rejection tests for unlink, queue, assets schema (#236)#241
Merged
test: substring-rejection tests for unlink, queue, assets schema (#236)#241
Conversation
#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
There was a problem hiding this comment.
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
queuename single-substring input yieldsJrError::UserErrorwith 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends handler-level
partial_matchsingle-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 firesqueue resolve(library test onresolve_queue_by_name) — complements existingExactMultipletest; assertsJrError::UserErrorvia downcastassets schema --schema(binary test) —jr assets schema AnyType --schema its→ exit 64,Ambiguous schema, no object-type listing firesEach 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 throughAmbiguous).Scope
This PR covers 3 of the 8 call sites listed in #236. The remaining 5 are deferred to #240:
helpers.rsteam/user/asset resolution — usesbail!(exit 1) and needs a parallel refactor similar to refactor: unify exit codes for ambiguous input — move/link currently exit 1, list exits 64 #237assets search --status— needs AQL + ticket-enrichment plumbingassets schema <type_name>object-type match — needs schemas + objecttypes/flat mocksDesign choices
jr queue viewrequires project-meta + service-desk discovery + queue list mocks (3 chained mocks). The test precedent atqueue.rs:190(resolve_queue_duplicate_names_error_message) is library-level; this PR mirrors that pattern for the Ambiguous variant.Ambiguous link typeassertions this implicitly locks the short-circuit..expect(0)on bothobjecttypes/flatendpoints — explicit short-circuit assertion.Test plan
cargo fmt --all -- --checkcleancargo clippy --all-targets -- -D warningscleancargo test— 806 passed, 0 failed (+3 new over baseline 803)Refs #236