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

Streaming responses are not streamed #7

Open
mseremin opened this issue Jul 8, 2020 · 1 comment
Open

Streaming responses are not streamed #7

mseremin opened this issue Jul 8, 2020 · 1 comment

Comments

@mseremin
Copy link

mseremin commented Jul 8, 2020

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?

@cbrz
Copy link
Owner

cbrz commented Jul 12, 2020

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!

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

No branches or pull requests

2 participants