-
Notifications
You must be signed in to change notification settings - Fork 414
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
Expose public creation methods for GRPCAsyncRequestStream
and GRPCAsyncResponseStreamWriter
#1485
Conversation
b4080dc
to
c05cff8
Compare
c05cff8
to
a03206c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm a bit lost, but what's the intended use of RecordingWriter
?
Sure, maybe I should have put more context in the description. The problem that we have at the moment is that if you implement a method that writing a stream of responses and subsequently you want to write a test for your implementation then you really can't do this since you can't instantiate The goal of this PR is to make it possible to write unit tests for implementation of generated protocol methods. More specifically for the methods that have either request/response streams. |
Ok, that makes sense. Can you provide this as a detailed doc comment on the type? It'll make it much easier for users to discover the intended use of this object. |
Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStreamWriter.swift
Outdated
Show resolved
Hide resolved
Tests/GRPCTests/AsyncAwaitSupport/GRPCAsyncRequestStreamTests.swift
Outdated
Show resolved
Hide resolved
/// This struct contains two properties: | ||
/// 1. The ``writer`` which is the actual ``GRPCAsyncResponseStreamWriter`` and should be passed to the method under testing. | ||
/// 2. The ``stream`` which can be used to observe the written responses. | ||
public struct ResponseStreamWriter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the naming a little clearer that it's for testing? The names on the request side are 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah slightly awkward naming these types. I ended up with TestingStreamWriter
and makeTestingResponseStreamWriter()
which aligns with the request side
…nseStreamWriter` # Motivation It is highly desirable to be able to write tests against the generated method of a service. Currently, this is close to impossible since both the `GRPCAsyncRequestStream` and the `GRPCAsyncResponseStreamWriter` don't expose a public init so users cannot drive and observe the functions. # Modification Adds new public methods to drive and observe the request stream and the response writer. # Result We can now properly test gRPC generated server function implementations.
750d484
to
3b272e9
Compare
…AsyncResponseStreamWriter` (grpc#1485) Motivation: It is highly desirable to be able to write tests against the generated method of a service. Currently, this is close to impossible since both the `GRPCAsyncRequestStream` and the `GRPCAsyncResponseStreamWriter` don't expose a public init so users cannot drive and observe the functions. Modification: Adds new public methods to drive and observe the request stream and the response writer. Result We can now test functions which use the request stream and response stream writer.
…AsyncResponseStreamWriter` (grpc#1485) Motivation: It is highly desirable to be able to write tests against the generated method of a service. Currently, this is close to impossible since both the `GRPCAsyncRequestStream` and the `GRPCAsyncResponseStreamWriter` don't expose a public init so users cannot drive and observe the functions. Modification: Adds new public methods to drive and observe the request stream and the response writer. Result We can now test functions which use the request stream and response stream writer.
Motivation
It is highly desirable to be able to write tests against the generated method of a service. Currently, this is close to impossible since both the
GRPCAsyncRequestStream
and theGRPCAsyncResponseStreamWriter
don't expose a public init so users cannot drive and observe the functions.Modification
Adds new public methods to drive and observe the request stream and the response writer.
Result
We can now properly test gRPC generated server function implementations.