Skip to content

Conversation

@mpetrov
Copy link
Contributor

@mpetrov mpetrov commented Mar 6, 2019

This enables instantiating CallResult structs for test stubs.

mpetrov added 2 commits March 6, 2019 09:38
This enables instantiating CallResult structs for test stubs.
@fandyfyf
Copy link

fandyfyf commented Mar 6, 2019

👍

Copy link
Collaborator

@MrMage MrMage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but would you mind providing a short example illustrating when these are needed to write tests?

@mpetrov
Copy link
Contributor Author

mpetrov commented Mar 6, 2019

Thanks Daniel!

This could be used for stubbing out the async calls as follows:

  override func get(_ request: Echo_EchoRequest, metadata customMetadata: Metadata, completion: @escaping (Echo_EchoResponse?, CallResult) -> Void) throws -> Echo_EchoGetCall {
    completion(nil, .error(statusCode: .notFound))

The bazel rules don't currently enable stub generation, but once that's in place I'll likely also change the default stub code as well.

@MrMage
Copy link
Collaborator

MrMage commented Mar 6, 2019

Makes sense, thank you for the elaboration!

@MrMage MrMage merged commit 140d34a into grpc:master Mar 6, 2019
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

Successfully merging this pull request may close these issues.

3 participants