-
Notifications
You must be signed in to change notification settings - Fork 38
fix(model/test): dont attempt to resolve store files against a basepath as they are already complete #603
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
Conversation
… test and store import
WalkthroughChanges to cmd/model/test.go remove the path package import and modify the ReadFromFile call to pass an empty string instead of path.Dir(file) for the base directory argument. Additionally, new test fixture and configuration files are added to support relative path testing scenarios for model and store imports. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used🧬 Code graph analysis (1)cmd/model/test.go (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…th as they are already complete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the model test command to properly handle stores with relative file paths. Previously, the command was passing path.Dir(file) as the basePath parameter to ReadFromFile, which caused issues with nested relative paths. The fix changes this to pass an empty string, allowing ReadFromFile to determine the base path correctly from the file itself.
- Changed the
ReadFromFilecall incmd/model/test.goto pass an empty string instead ofpath.Dir(file)as the basePath parameter - Added test cases to verify handling of relative paths in store files
- Removed the unused
pathpackage import
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/model/test.go | Changed ReadFromFile call to pass empty string for basePath parameter and removed unused path import |
| tests/model-test-cases.yaml | Added new test file with test cases for absolute paths, relative paths, glob patterns, and relative paths in store files |
| tests/import-tests-cases.yaml | Added test case for importing a store with relative paths |
| tests/fixtures/relative-path/relative-path-store.fga.yaml | Added new test fixture with relative paths to model and tuple files |
Comments suppressed due to low confidence (1)
cmd/model/test.go:1
- [nitpick] Consider using
filepath.Dir(file)instead of an empty string to maintain consistency with theReadFromFileimplementation. While passing an empty string works becauseReadFromFileinternally usesfilepath.Dir(absFileName)(line 60 ininternal/storetest/read-from-input.go), explicitly passing the directory makes the code's intent clearer and reduces coupling to internal implementation details.
/*
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
pushing tests first to ensure they fail in CI and then will push fix
What problem is being solved?
Currently we're passing in the base path when reading store files in
fga model testdespite these not needing any further resolving.How is it being solved?
Dont pass the basepath argument into
ReadFromFileWhat changes are made to solve it?
☝🏻
References
closes openfga/action-openfga-test#32
Review Checklist
mainSummary by CodeRabbit
New Features
Tests