From b3c06c91e1b61c806f3fe3eae16bd53d43ed5cbc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 6 Jun 2026 01:35:16 +0000 Subject: [PATCH] test: reduce and improve tests in safeoutputs noop/link_work_items/result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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> --- src/safeoutputs/link_work_items.rs | 8 ++++---- src/safeoutputs/noop.rs | 13 ------------- src/safeoutputs/result.rs | 8 +------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/safeoutputs/link_work_items.rs b/src/safeoutputs/link_work_items.rs index 24dfcac3..69b43048 100644 --- a/src/safeoutputs/link_work_items.rs +++ b/src/safeoutputs/link_work_items.rs @@ -436,10 +436,10 @@ allowed-link-types: - related "#; let config: LinkWorkItemsConfig = serde_yaml::from_str(yaml).unwrap(); - assert_eq!(config.allowed_link_types.len(), 3); - assert!(config.allowed_link_types.contains(&"parent".to_string())); - assert!(config.allowed_link_types.contains(&"child".to_string())); - assert!(config.allowed_link_types.contains(&"related".to_string())); + assert_eq!( + config.allowed_link_types, + vec!["parent", "child", "related"] + ); } #[test] diff --git a/src/safeoutputs/noop.rs b/src/safeoutputs/noop.rs index 5575f6d5..115e705e 100644 --- a/src/safeoutputs/noop.rs +++ b/src/safeoutputs/noop.rs @@ -116,19 +116,6 @@ mod tests { assert_eq!(NoopResult::NAME, "noop"); } - #[test] - fn test_result_serializes_correctly() { - let result: NoopResult = NoopParams { - context: Some("test context".to_string()), - } - .try_into() - .unwrap(); - let json = serde_json::to_string(&result).unwrap(); - - assert!(json.contains(r#""name":"noop""#)); - assert!(json.contains(r#""context":"test context""#)); - } - #[test] fn test_result_serializes_to_valid_json() { let result: NoopResult = NoopParams { diff --git a/src/safeoutputs/result.rs b/src/safeoutputs/result.rs index c08c24c2..32854021 100644 --- a/src/safeoutputs/result.rs +++ b/src/safeoutputs/result.rs @@ -701,7 +701,7 @@ mod tests { fn test_anyhow_to_mcp_error_preserves_message() { let err = anyhow::anyhow!("test error message"); let mcp_err = anyhow_to_mcp_error(err); - assert!(mcp_err.message.contains("test error message")); + assert_eq!(mcp_err.message, "test error message"); } #[test] @@ -858,12 +858,6 @@ mod tests { assert_eq!(ctx.source_version.as_deref(), Some("abc1234")); } - #[test] - fn test_from_env_lookup_build_id_parses_numeric() { - let ctx = ExecutionContext::from_env_lookup(env_from(&[("BUILD_BUILDID", "987654")])); - assert_eq!(ctx.build_id, Some(987654)); - } - #[test] fn test_from_env_lookup_build_id_none_for_non_numeric() { let ctx = ExecutionContext::from_env_lookup(env_from(&[("BUILD_BUILDID", "not-a-number")]));