Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(policy): improve engine test coverage #1055

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

thevilledev
Copy link
Contributor

@thevilledev thevilledev commented Feb 1, 2025

Add TestLoadWithData and TestNamespaces to increase test coverage for the policy engine. Tests a few edge cases such as duplicate namespaces.

The tests were previously using a custom memfs implementation from the repo, which was built for testing purposes only. This PR replaces that with the official Go testing/fstest package.

Increases test coverage from 69.1% to 87.7% for the policy package.

Add TestLoadWithData and TestNamespaces to increase test coverage for the
policy engine. Tests a few edge cases such as duplicate namespaces.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
Migrate tests to use Go's standard library fstest.MapFS instead of
custom memfs implementation.

- Update TestProblematicIf and TestNamespaces to use fstest.MapFS
- Remove memfs import and dependency
- Convert test file content handling to use MapFile structs
- Maintain existing test functionality while using official FS impl

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
The type conversion from map[string]*fstest.MapFile to fstest.MapFS triggers
an 'unnecessary conversion' linter warning. Add explanatory comment to
document why this conversion is required - it ensures proper fs.FS interface
implementation needed by loader.WithFS.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
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