Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ewanharris
Copy link
Member

@ewanharris ewanharris commented Nov 5, 2025

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 test despite these not needing any further resolving.

How is it being solved?

Dont pass the basepath argument into ReadFromFile

What changes are made to solve it?

☝🏻

References

closes openfga/action-openfga-test#32

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Summary by CodeRabbit

  • New Features

    • Enhanced store imports to support relative path references between configuration files.
  • Tests

    • Added comprehensive test coverage for various path specifications including absolute paths, relative paths, glob patterns, and nested directory paths in store configurations.

Copilot AI review requested due to automatic review settings November 5, 2025 14:40
@ewanharris ewanharris requested a review from a team as a code owner November 5, 2025 14:40
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Walkthrough

Changes 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

Cohort / File(s) Summary
Core Code Update
cmd/model/test.go
Removed path package import and changed ReadFromFile base directory argument from path.Dir(file) to empty string ""
Test Fixtures and Configurations
tests/fixtures/relative-path/relative-path-store.fga.yaml
tests/import-tests-cases.yaml
tests/model-test-cases.yaml
Added new fixture file with relative path references to model and tuple files; added test case 002 to import-tests-cases.yaml for relative path store import; added new model-test-cases.yaml with four test scenarios using absolute paths, relative paths, glob patterns, and nested directory paths

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • rhamzeh
  • Siddhant-K-code
  • sergiught

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing basepath argument from store file resolution in model/test, which is the core fix across all modified files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/running-tests

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5566a9 and 1033c1b.

📒 Files selected for processing (4)
  • cmd/model/test.go (1 hunks)
  • tests/fixtures/relative-path/relative-path-store.fga.yaml (1 hunks)
  • tests/import-tests-cases.yaml (1 hunks)
  • tests/model-test-cases.yaml (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/model/test.go (1)
internal/storetest/read-from-input.go (1)
  • ReadFromFile (30-77)
🔇 Additional comments (4)
tests/import-tests-cases.yaml (1)

11-16: LGTM! Good test coverage for relative path handling.

This test case appropriately validates that store imports work correctly with relative paths, complementing the fix in cmd/model/test.go.

cmd/model/test.go (1)

79-79: Correct fix for basePath handling.

Passing an empty string as basePath is the right approach. The ReadFromFile function internally uses filepath.Dir(absFileName) to resolve nested file references (model_file, tuple_file) relative to the store file's actual location. The previous code incorrectly passed path.Dir(file), which would have caused double-resolution issues when file was already a relative or absolute path.

tests/model-test-cases.yaml (1)

1-20: Excellent test coverage for path handling scenarios.

These test cases comprehensively validate different path resolution scenarios:

  • Absolute paths with ./ prefix
  • Relative paths without prefix
  • Glob pattern expansion
  • Nested directories with relative file references

This thorough coverage ensures the fix in cmd/model/test.go handles all common use cases correctly.

tests/fixtures/relative-path/relative-path-store.fga.yaml (1)

1-10: Good fixture for testing relative path resolution.

This fixture effectively tests the fix by using relative paths (../) for model and tuple files. The referenced files exist at the expected locations and the test assertion is sufficient for validating that path resolution works correctly with the fix in cmd/model/test.go.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ewanharris ewanharris changed the title test: add integration tests to cover different path variants in model… fix(model/test): dont attempt to resolve store files against a basepath as they are already complete Nov 5, 2025
Copy link

Copilot AI left a 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 ReadFromFile call in cmd/model/test.go to pass an empty string instead of path.Dir(file) as the basePath parameter
  • Added test cases to verify handling of relative paths in store files
  • Removed the unused path package 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 the ReadFromFile implementation. While passing an empty string works because ReadFromFile internally uses filepath.Dir(absFileName) (line 60 in internal/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.

@ewanharris ewanharris added this pull request to the merge queue Nov 5, 2025
Merged via the queue into main with commit db7dfeb Nov 5, 2025
22 checks passed
@ewanharris ewanharris deleted the fix/running-tests branch November 5, 2025 15:19
@coderabbitai coderabbitai bot mentioned this pull request Nov 5, 2025
4 tasks
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.

test path parameter is broken since upgrading to openFGA CLI 0.7.7

3 participants