mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Save mappings to files #561
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 @MindaugasLaganeckas on GitHub (Dec 8, 2023).
Originally assigned to: @StefH on GitHub.
Describe the bug
Missing mapping files in case the request URL is the same AND the HTTP request method is the same, BUT the request data is different.
This bug breaks our record mapping files and replay tests using local mapping files flow.
Expected behavior:
Even though I use the same request URL and the same HTTP request method, but as long as I change the request data, I expect to get a mapping file for every such request.
Test to reproduce
Start wiremock server in the examples/Wiremock.Net.Console.Proxy.NetCoreApp
Execute
curl -d "param1=value1¶m2=value2" -X POST http://localhost:9091/post
curl -d "param10=value10¶m20=value20" -X POST http://localhost:9091/post
Expected behavior: find 2 different mapping files in the __admin/mappings folder one for each request.
Actual behavior: 1 mapping file in the __admin/mappings folder containing the latest request/response data.
Other info.
I am willing to work on the issue since it is a blocker for our test execution.
Would you have any suggestions of how to fix it?
My inputs:
A naïve approach would be to add GUID to the name of the mapping file before saving it.
I am not sure whether a more sophisticated approach is needed.
@StefH commented on GitHub (Dec 8, 2023):
You are correct, the mapping file is named
Proxy Mapping for POST _post.jsonwhich is the same in both cases.A possible solution for this is to add the hashcode from the mapping also in the filename. In that case you'll get 2 files.
@StefH commented on GitHub (Dec 8, 2023):
Or just append a random Guid in this scenario as you suggest, but this should be configurable in the ProxyAndRecordSettings
@StefH commented on GitHub (Dec 8, 2023):
Ah...
It's already supported with
AppendGuidToSavedMappingFileboolean.@MindaugasLaganeckas commented on GitHub (Dec 9, 2023):
Wow! Thank you so much for a quick reply! I will try it out on Monday and will return to you. 🎄
@MindaugasLaganeckas commented on GitHub (Dec 11, 2023):
Thank you! The flag works as expected.