-
Notifications
You must be signed in to change notification settings - Fork 38
feat: use relative path in model_file in tests #516
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
feat: use relative path in model_file in tests #516
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughIntroduces conditional path resolution in internal/storetest/read-from-input.go: when a basePath is provided and fileName is relative, the code computes an absolute path and opens the file using it. Error reporting continues to reference the original fileName. No exported/public signatures changed. Changes
Sequence Diagram(s)sequenceDiagram
actor Caller
participant Func as read-from-input
participant FS as Filesystem
Caller->>Func: read(fileName, basePath)
alt fileName is absolute or no basePath
Note over Func: absFileName = fileName
else relative fileName and basePath provided
Note over Func: absFileName = join(basePath, fileName)
end
Func->>FS: open(absFileName)
alt open fails
FS-->>Func: error
Func-->>Caller: error (mentions original fileName)
else open succeeds
FS-->>Func: handle
Func-->>Caller: data/result
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing touches🧪 Generate unit tests (beta)
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 |
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
internal/storetest/read-from-input.go (2)
35-39: Variable name is misleading; also consider cleaning the joined path.absFileName may still be relative if basePath is relative. Rename to resolvedPath and apply filepath.Clean to normalize.
- absFileName := fileName + resolvedPath := fileName - if !filepath.IsAbs(fileName) && basePath != "" { - absFileName = filepath.Join(basePath, fileName) - } + if !filepath.IsAbs(fileName) && basePath != "" { + resolvedPath = filepath.Clean(filepath.Join(basePath, fileName)) + }
49-52: Mirror the improved error message for YAML unmarshal.Keep the user-supplied name and also report the resolved path.
- return format, nil, fmt.Errorf("failed to unmarshal file %s due to %w", fileName, err) + return format, nil, fmt.Errorf("failed to unmarshal file %q (resolved path: %q): %w", fileName, absFileName, err)If you adopted the resolvedPath rename, use that identifier instead of absFileName.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
internal/storetest/read-from-input.go(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test Release Process
- GitHub Check: Tests
🔇 Additional comments (1)
internal/storetest/read-from-input.go (1)
22-22: Import addition is appropriate.Adding path/filepath is necessary for the new path resolution logic.
|
@SoulPancake, can you please address the review comments & fix the CI please! |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Fix lint failures and integration test issues --------- Co-authored-by: SoulPancake <[email protected]>
|
@Siddhant-K-code Hi |
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.
Changes look good and are backward compatible. Thanks @SoulPancake!
Before merging, please add this to CHANGELOG.md under Unreleased:
Fixed:
- Fix relative path resolution in `model test` to resolve paths relative to test file location instead of CWD ([#516](https://github.com/openfga/cli/pull/516)) - fixes #349|
Done, Please have a look @Siddhant-K-code |
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.
LGTM 🚀
@openfga/dx, can you give a ✅ to unblock the merge queue.
Fixes #349
Description
References
Review Checklist
mainSummary by CodeRabbit