🧪 test: implement unit testing for fleet HasCritical#147
Conversation
Added unit tests to `internal/fleet/fleet_test.go` covering the missing scenarios for the `HasCritical` function. Tests cover empty inputs, parsing variations (e.g. `critical: 0`, `critical:0`), mixed results, and scenarios with error values to ensure correct conditional logic execution. Includes standard license header and table-driven testing pattern in line with existing codebase practices. Co-authored-by: jackby03 <70082129+jackby03@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What: The testing gap for the
fleet.HasCriticalfunction has been addressed by introducing unit tests ininternal/fleet/fleet_test.go. Previously, this pure function responsible for extracting critical severity occurrences fromHostResultoutputs lacked testing.📊 Coverage: The test cases using table-driven logic now cover:
"critical":0and"critical": 0(which correctly returnfalse)"critical": 1or with extra whitespace (which correctly returntrue)Errfield (non-OK results) are appropriately ignored, avoiding false positives.✨ Result: The
HasCriticallogic is now fully covered by deterministic tests, providing a robust safety net against future refactoring or logic changes to error parsing in the fleet module.PR created automatically by Jules for task 13630435664046139039 started by @jackby03