test: reduce and improve tests in safeoutputs noop/link_work_items/result#874
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
…sult - noop.rs: remove test_result_serializes_correctly (weaker duplicate of test_result_serializes_to_valid_json; both test the same two JSON fields but the removed test used contains() string checks instead of proper serde_json::Value access) - result.rs: remove test_from_env_lookup_build_id_parses_numeric (strict subset of test_from_env_lookup_populates_build_fields which already asserts ctx.build_id == Some(12345) via the identical code path) - link_work_items.rs: rewrite test_config_deserializes_from_yaml from four separate len()+contains() assertions to a single assert_eq! that also verifies Vec ordering - result.rs: rewrite test_anyhow_to_mcp_error_preserves_message to use assert_eq! instead of contains() — the message passes through verbatim so an exact equality check is both correct and more precise Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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/safeoutputs/What was wrong
noop.rs—test_result_serializes_correctly: duplicate oftest_result_serializes_to_valid_json. Both tests create aNoopResultand assert on thenameandcontextJSON fields. The removed test used fragilecontains()string checks; the retained test uses properserde_json::Valueaccess and is strictly more rigorous.result.rs—test_from_env_lookup_build_id_parses_numeric: strict subset oftest_from_env_lookup_populates_build_fields. The larger test already setsBUILD_BUILDIDand assertsctx.build_id == Some(12345)through the identical code path. The removed test added nothing beyond the existing assertion.link_work_items.rs—test_config_deserializes_from_yaml: used four separate assertions (len() == 3+ threecontains()calls) instead of a singleassert_eq!. The old form did not verifyVecordering (YAML arrays are ordered) and was unnecessarily verbose.result.rs—test_anyhow_to_mcp_error_preserves_message: usedassert!(mcp_err.message.contains("test error message")). Because the anyhow message passes through verbatim (err.to_string().into()),assert_eq!is both correct and more precise — it would catch unintended wrapping or prefixing thatcontains()would silently allow.Changes
src/safeoutputs/noop.rstest_result_serializes_correctlysrc/safeoutputs/result.rstest_from_env_lookup_build_id_parses_numericsrc/safeoutputs/link_work_items.rstest_config_deserializes_from_yamlsrc/safeoutputs/result.rstest_anyhow_to_mcp_error_preserves_messageVerification
cargo test: all tests pass ✅cargo clippy --all-targets --all-features: no errors or warnings ✅Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comspsprodweu4.vssps.visualstudio.comSee Network Configuration for more information.