Skip to content

test: fix vacuous assertions in create_work_item and update_work_item#1603

Merged
jamesadevine merged 1 commit into
mainfrom
test/fix-bare-is-err-assertions-2-3edc5978968844f5
Jul 22, 2026
Merged

test: fix vacuous assertions in create_work_item and update_work_item#1603
jamesadevine merged 1 commit into
mainfrom
test/fix-bare-is-err-assertions-2-3edc5978968844f5

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Test Suite Reduction: src/safe_outputs/create_work_item.rs + update_work_item.rs

What was wrong

  • test_validation_rejects_short_title (create_work_item): used bare assert!(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 — bare assert!(result.is_err()) with no message check.
  • test_validation_rejects_tag_with_semicolon (create_work_item): bare assert!(result.is_err()) with no message check, despite a descriptive error message being available.
  • test_params_validates_title_length (update_work_item): bare assert!(result.is_err()) — doesn't verify the "255 characters or fewer" message.

In addition, the two bare ensure!() calls in CreateWorkItemParams::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

File Test Action Reason
create_work_item.rs test_validation_rejects_short_title Rewritten Bare is_err()unwrap_err() + "title must be more than 5 characters"
create_work_item.rs test_validation_rejects_short_description Rewritten Bare is_err()unwrap_err() + "description must be more than 30 characters"
create_work_item.rs test_validation_rejects_tag_with_semicolon Rewritten Bare is_err()unwrap_err() + "semicolon"
create_work_item.rs CreateWorkItemParams::validate() Implementation fix Added descriptive messages to the two bare ensure!() calls so tests have something meaningful to assert
update_work_item.rs test_params_validates_title_length Rewritten Bare is_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.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "spsprodeus21.vssps.visualstudio.com"

See Network Configuration for more information.

Generated by Test Reducer · 100.5 AIC · ⌖ 12 AIC · ⊞ 8.7K ·

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>
@github-actions github-actions Bot mentioned this pull request Jul 22, 2026
@jamesadevine
jamesadevine marked this pull request as ready for review July 22, 2026 20:54
@jamesadevine
jamesadevine merged commit 3b13e35 into main Jul 22, 2026
6 of 8 checks passed
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.

1 participant