mountebank-grpc
mountebank-grpc copied to clipboard
Streaming responses are not streamed
I try to mock unary-stream response, but I get answer like unary. I mean that in BloomPRC my mock answered to me one time, it is not streaming. Can someone help me to know what I'm doing wrong and explain how I must configure my imposter to get stream response?
Hey @mseremin, sorry for the late response.
I'm not sure if you figured it out yet... to mock a streaming response, you can use a list in the 'value' with multiple responses. When the imposter is setup this way, it'll send back all of values.
Here's an example imposter using the protos from the src/protos directory:
{
"protocol": "grpc",
"port": 4545,
"loglevel": "debug",
"recordRequests": true,
"services": {
"example.ExampleService": {
"file": "example.proto"
}
},
"options": {
"protobufjs": {
"includeDirs": ["/home/cbrz/dev/mbtest/mountebank-grpc/src/protos"]
}
},
"stubs": [{
"predicates": [
{
"matches": { "path": "UnaryStream" },
"caseSensitive": false
}
],
"responses": [
{
"is": {
"value": [
{
"id": 100,
"data": "mock stream response"
},
{
"id": 101,
"data": "mock stream response"
}
]
}
}
]
}]
}
Send a unary request calling the UnaryStream endpoint and you should see two responses.
Let me know if you have any questions/comments. Thanks!