mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
grpc multiple request/response in single mock #652
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 @GomesNayagam on GitHub (Dec 19, 2024).
Originally assigned to: @StefH on GitHub.
Ask question related to the repo, e.g:
How to to achieve feeding multiple request and response in single server url setup
e.g
sample proto:
@StefH commented on GitHub (Dec 19, 2024):
Defining and using multiple Grpc Protobuf mappings is not different then defining multiple normal mappings.
So in your case you need to define 2 mappings with 2 different request paths and 2 different respones.
So instead of
.WithPath("/Policy.PolicyService2/**"), you need:Mapping 1
.WithPath("/Policy.PolicyService2/GetVersion")and use response
Mapping 2
.WithPath("/Policy.PolicyService2/GetVersion2")and use response
@GomesNayagam commented on GitHub (Dec 20, 2024):
thanks for quick response @StefH and is there any way to use some json file rather declarative way?
@StefH commented on GitHub (Dec 20, 2024):
yes this is possible.
However I cannot find an example quickly.
What you can do is run this code in console app and then accesss the /mapings endpoint to retrieve it as json
@StefH commented on GitHub (Dec 21, 2024):
@GomesNayagam
An example could be:
@GomesNayagam commented on GitHub (Dec 27, 2024):
@StefH how do i use this in code like the wiremocktestcontainer support _files and _mapping, how could i use this. pls.
@StefH commented on GitHub (Dec 27, 2024):
Just create a mappings.json file, add the mapping as json text and put this file somewhere.
Then see this example:
https://github.com/WireMock-Net/WireMock.Net/blob/master/examples/WireMock.Net.TestcontainersExample/Program.cs#L167
@GomesNayagam commented on GitHub (Dec 27, 2024):
@StefH will grpc works with testcontainer? WireMockContainerBuilder? can you provide simple full e.g?