Skip to content
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

.WithBodyFromFile() + .WithTransformer(transformContentFromBodyAsFile: true) = empty string #1184

Closed
vitalyve opened this issue Sep 28, 2024 · 4 comments
Assignees
Labels

Comments

@vitalyve
Copy link

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 vitalyve added the bug label Sep 28, 2024
@StefH StefH self-assigned this Sep 29, 2024
@vitalyve
Copy link
Author

vitalyve commented 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
Copy link
Collaborator

StefH commented 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
Copy link
Collaborator

StefH commented Sep 29, 2024

Changing the internal logic is some work.

Adding a check and throw exception is better for now.

See PR:
#1185

@vitalyve
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants