test(policy): move fuzz tests from core to policy and add unit tests
Purpose of PR?: This PR moves the fuzz tests (containerPolicy_fuzz_test and hostPolicy_fuzz_test) from the core package into the policy package and merges them into policy_test.go. Additionally, it introduces new unit tests for both container and host policy handlers to increase coverage and validate expected behavior.
Fuzz Tests (moved and merged): FuzzContainerPolicy FuzzHostPolicy These were originally in the core package and are now placed in policy/policy_test.go.
New Unit Tests: TestContainerPolicy Covers: disabled state, invalid JSON, empty metadata, and valid policy application. TestHostPolicy Covers: disabled state, invalid JSON, empty metadata, and valid policy application. These tests verify policy parsing, handling, update calls, and correct status responses (NotEnabled, Invalid, Applied).
Coverage Metrics Before the changes: 0% coverage for the policy package
After adding the merged fuzz tests and new unit tests: coverage: 100.0% of statements for policy package
Fixes #
Does this PR introduce a breaking change? No
If the changes in this PR are manually verified, list down the scenarios covered::
Additional information for reviewer? : Mention if this PR is part of any design or a continuation of previous PRs
Checklist:
- [ ] Bug fix. Fixes #
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
- [x] PR Title follows the convention of
<type>(<scope>): <subject> - [x] Commit has unit tests
- [ ] Commit has integration tests
@GAURAV-DEEP01 can you update PR description with briefing the tests that been added and the coverage metric for the test file, thanks.
done @rksharma95