Skip to content

🧪 test: implement unit testing for fleet HasCritical#147

Merged
jackby03 merged 1 commit intomainfrom
test/fleet-hascritical-coverage-13630435664046139039
Apr 13, 2026
Merged

🧪 test: implement unit testing for fleet HasCritical#147
jackby03 merged 1 commit intomainfrom
test/fleet-hascritical-coverage-13630435664046139039

Conversation

@jackby03
Copy link
Copy Markdown
Owner

🎯 What: The testing gap for the fleet.HasCritical function has been addressed by introducing unit tests in internal/fleet/fleet_test.go. Previously, this pure function responsible for extracting critical severity occurrences from HostResult outputs lacked testing.

📊 Coverage: The test cases using table-driven logic now cover:

  • Empty result sets
  • Results missing the "critical" JSON key
  • Results formatted as "critical":0 and "critical": 0 (which correctly return false)
  • Results formatted as "critical": 1 or with extra whitespace (which correctly return true)
  • Mixed results (results with no criticals and some with criticals)
  • Checking that results with a non-nil Err field (non-OK results) are appropriately ignored, avoiding false positives.

Result: The HasCritical logic 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

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>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@jackby03 jackby03 merged commit bcbf753 into main Apr 13, 2026
12 checks passed
@jackby03 jackby03 deleted the test/fleet-hascritical-coverage-13630435664046139039 branch April 13, 2026 04:57
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