From 37eef1a95b8c497875498746b9f089bd57d31363 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 19 Jul 2026 13:02:40 +0000 Subject: [PATCH] test: fix vacuous is_err() assertions in create_git_tag and comment_on_work_item Replace bare assert!(result.is_err()) with unwrap_err() + message content assertions so regressions that produce the wrong error cannot silently pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/safe_outputs/comment_on_work_item.rs | 18 +++++++++++++++--- src/safe_outputs/create_git_tag.rs | 12 ++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/safe_outputs/comment_on_work_item.rs b/src/safe_outputs/comment_on_work_item.rs index 7adab3ae..5d64b116 100644 --- a/src/safe_outputs/comment_on_work_item.rs +++ b/src/safe_outputs/comment_on_work_item.rs @@ -387,7 +387,11 @@ mod tests { body: "This is a valid comment body text.".to_string(), }; let result: Result = params.try_into(); - assert!(result.is_err()); + let err = result.unwrap_err().to_string(); + assert!( + err.contains("work_item_id must be positive"), + "unexpected error: {err}" + ); } #[test] @@ -397,7 +401,11 @@ mod tests { body: "This is a valid comment body text.".to_string(), }; let result: Result = params.try_into(); - assert!(result.is_err()); + let err = result.unwrap_err().to_string(); + assert!( + err.contains("work_item_id must be positive"), + "unexpected error: {err}" + ); } #[test] @@ -407,7 +415,11 @@ mod tests { body: "Too short".to_string(), }; let result: Result = params.try_into(); - assert!(result.is_err()); + let err = result.unwrap_err().to_string(); + assert!( + err.contains("body must be at least 10 characters"), + "unexpected error: {err}" + ); } #[test] diff --git a/src/safe_outputs/create_git_tag.rs b/src/safe_outputs/create_git_tag.rs index 92a88df5..2dd8f1e9 100644 --- a/src/safe_outputs/create_git_tag.rs +++ b/src/safe_outputs/create_git_tag.rs @@ -463,7 +463,11 @@ mod tests { repository: None, }; let result: Result = params.try_into(); - assert!(result.is_err()); + let err = result.unwrap_err().to_string(); + assert!( + err.contains("message must be at least 5 characters"), + "unexpected error: {err}" + ); } #[test] @@ -475,7 +479,11 @@ mod tests { repository: Some("##vso[task.setvariable variable=x]y".to_string()), }; let result: Result = params.try_into(); - assert!(result.is_err()); + let err = result.unwrap_err().to_string(); + assert!( + err.contains("pipeline command"), + "unexpected error: {err}" + ); } #[test]