-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
Improved relative path checking based on file existence #411
Improved relative path checking based on file existence #411
Conversation
If the file exists at the relative path, then use it. If not, then use the path as is.
Before this fix, providing a relative path failed. For example: If we have a folder at Then the only way to reach this file was by providing an absolute path. Since if the user provided |
@StefH How is it that my unit tests are all passing locally but failing on the CI? Any idea? |
I've 2 CI builds
And it seems that Linux is failing:
I think the |
Great tip! Thank you. I think this syntax will be good enough to support both platforms:
Also, the build is still failing and I think wrapping the |
The best is to move this Clean path logic to a new class. Like: And the logic should be :
After the above logic: Does this make sense? |
test/WireMock.Net.Tests/ResponseBuilders/ResponseWithBodyFromFileTests.cs
Outdated
Show resolved
Hide resolved
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.
- please see comments
- and the CI Linux still fails it seems?
Add another test to ResponseWithBodyFromFileTests
Linux CI keeps failing. It started failing on 9bc737f when I tried dealing with slashes. |
The issue was in removing the leading directory separator character, the absolute path on Linux systems (which begins with such a character) was broken. I moved the "remove leading dir sep char" logic inside Path.Combine call so it's called only when absolutely necessary as an extra defense against users who provide paths with leading \ or /. |
test/WireMock.Net.Tests/ResponseBuilders/ResponseWithBodyFromFileTests.cs
Outdated
Show resolved
Hide resolved
test/WireMock.Net.Tests/ResponseBuilders/ResponseWithBodyFromFileTests.cs
Outdated
Show resolved
Hide resolved
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.
I don't seem to be able to approve this to resolve the merge conflicts.
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.
ok
I'll merge this one now to master. For that Delete RestApi change :
|
If the file exists at the relative path, then use it. If not, then use the path as is.
This is stronger than the previous check if the path is just the filename, since if it's just a file name then we'll check if the file exists at the relative path & then use if yes. Otherwise, use the path as is.