test: fix vacuous assertions in create_work_item and update_work_item#1603
Merged
jamesadevine merged 1 commit intoJul 22, 2026
Merged
Conversation
Replace bare assert!(result.is_err()) with unwrap_err() + message content checks so each test verifies the specific validation rule that was violated, not just that some error was returned. Also add descriptive messages to the bare ensure!() calls in CreateWorkItemParams::validate() so the tests have something meaningful to assert against. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Open
jamesadevine
marked this pull request as ready for review
July 22, 2026 20:54
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.
Test Suite Reduction:
src/safe_outputs/create_work_item.rs+update_work_item.rsWhat was wrong
test_validation_rejects_short_title(create_work_item): used bareassert!(result.is_err())— confirms some error occurred but not which validation rule fired, so a regression that changes the error could pass unnoticed.test_validation_rejects_short_description(create_work_item): same problem — bareassert!(result.is_err())with no message check.test_validation_rejects_tag_with_semicolon(create_work_item): bareassert!(result.is_err())with no message check, despite a descriptive error message being available.test_params_validates_title_length(update_work_item): bareassert!(result.is_err())— doesn't verify the "255 characters or fewer" message.In addition, the two bare
ensure!()calls inCreateWorkItemParams::validate()had no error messages, so any assertion against them would have been forced to match anyhow's internal condition-rendering format. This was fixed alongside the test rewrites.Changes
create_work_item.rstest_validation_rejects_short_titleis_err()→unwrap_err()+"title must be more than 5 characters"create_work_item.rstest_validation_rejects_short_descriptionis_err()→unwrap_err()+"description must be more than 30 characters"create_work_item.rstest_validation_rejects_tag_with_semicolonis_err()→unwrap_err()+"semicolon"create_work_item.rsCreateWorkItemParams::validate()ensure!()calls so tests have something meaningful to assertupdate_work_item.rstest_params_validates_title_lengthis_err()→unwrap_err()+"255 characters or fewer"Verification
cargo test: all tests pass ✅cargo check: clean ✅Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comSee Network Configuration for more information.