mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
.WithBodyFromFile() + .WithTransformer(transformContentFromBodyAsFile: true) = empty string #635
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vitalyve on GitHub (Sep 28, 2024).
Originally assigned to: @StefH on GitHub.
Describe the bug
When .WithBodyFromFile(responseFilePath) is used in combination with .WithTransformer(transformContentFromBodyAsFile: true) the server returns empty string.
Expected behavior:
The server should return transformed contents of the file.
Test to reproduce
I've created a project with tests to demonstrate the problem. Please look at it.
https://github.com/vitalyve/WireMockNetBodyFromFileWithTransformerBug
@vitalyve commented on GitHub (Sep 29, 2024):
Hi.
After some debugging of the WireMock.Net I've found that .WithTransformer(transformContentFromBodyAsFile: true) should be placed before .WithBodyFromFile() to be able to work as expected, but in examples form the Wiki it is placed after .WithBodyFromFile().
So, just need to update the article and the issue may be closed.
Anyway, thank you for the great project!
@StefH commented on GitHub (Sep 29, 2024):
Yes. I just made a branch with your testcase.
And indeed the order is important. However from a user perspective it should always work.
I will check if I can update the code.
@StefH commented on GitHub (Sep 29, 2024):
Changing the internal logic is some work.
Adding a check and throw exception is better for now.
See PR:
https://github.com/WireMock-Net/WireMock.Net/pull/1185
@vitalyve commented on GitHub (Sep 29, 2024):
Thank you!