spa: Fix TestURLToRelAcceptsSafeRelativePath for Windows cross-platform compatibility - #7274
spa: Fix TestURLToRelAcceptsSafeRelativePath for Windows cross-platform compatibility#7274nikunjkumar05 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: nikunjkumar05 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Updates the SPA path-safety test to accept OS-specific path separators.
Changes:
- Adds Windows OS detection.
- Uses backslashes in the Windows expectation.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
illume
left a comment
There was a problem hiding this comment.
Thanks for the contribution.
The backend test job in CI is failing. Run cd backend && go test ./... to reproduce the errors locally.
How to run the backend tests
Run cd backend && go test ./... to see all failures. Fix the failing tests and commit the result.
6e13bbb to
44a51e2
Compare
|
@illume thanks for review. Resolved the error. |
Summary
This PR fixes
TestURLToRelAcceptsSafeRelativePathtest failure on Windows by making the test expectation OS-aware usingruntime.GOOS.Changes
backend/pkg/spa/pathSafety_internal_test.goto handle Windows path separator conversion"headlamp\\assets\\main.js"on Windows and"headlamp/assets/main.js"on Linux/macOSSteps to Test
go test -count=1 ./pkg/spaon WindowsTestURLToRelAcceptsSafeRelativePathpassesNotes for the Reviewer
urlToRelfunction correctly produces OS-specific paths viafilepath.FromSlash()- the test expectation was written for Linux/macOS format only