-
Notifications
You must be signed in to change notification settings - Fork 420
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
ServiceTestStub methods not implemented #339
Comments
I am afraid that we indeed do not currently have an implementation for that. One idea would be to have the default implementation simply call the synchronous implementation and then call the completion handler with the result returned by the synchronous method. Would that work for you, and would you be interested in filing a pull request so we can integrate that into the project?
… On 4. Dec 2018, at 12:53, Carlos Pages ***@***.***> wrote:
I'm trying to test my grpc layer using ...ServiceTestStub.
If the rpc has a stream I can create all needed to test it. Also If the rpc doesn't have a stream but only if I use the synchronous method.
If I implement the asynchronous call I get an exception fatalError("not implemented")
In the code generated for the stubs seems that there is not implementation for this type of method:
func list_protocols(_ request: Xz_Rpc_Protocol_ListProtocolsRequest, completion: @escaping (Xz_Rpc_Protocol_ListProtocolsResponse?, CallResult) -> Void) throws -> Xz_Rpc_Protocol_ProtocolServicelist_protocolsCall {
fatalError("not implemented")
}
Do I have to create the stub manually to test this type of rpc's?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yeah I could try. Because the code is generated I guess is not that simple to implement it in the .grpc file. Could you point me where I can create the implementation so it's generated when the script is run? |
Sure, thank you! I think the code should be in `Generator-Client.swift` (try searching for `fatalError`) in the plugin source directory. To test your changes, run `make test-plugin` and copy `/tmp/echo.grpc.swift` (I think) to the repo. I would also suggest adding a test illustrating use of this stub to the existing "ClientTestExamples" (or similar, im on the phone right now) test suite. Let me know if you need any further guidance :-)
… On 4. Dec 2018, at 13:36, Carlos Pages ***@***.***> wrote:
Yeah I could try.
Because the code is generated I guess is not that simple to implement it in the .grpc file.
Could you point me where I can create the implementation so it's generated when the script is run?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@MrMage trying to follow your advise of implementing the synchronous call and call back to the completion closure I came across two problems: the |
@MrMage after diving a bit more in the code, I could mock the
The line But I'm pretty sure I could use in the If you are happy, I could try to implement this in the generator. If not, I hope this doesn't seem like a totally atrocity :S |
Ouch! Sorry, I had forgotten that
And then implement the method as follows:
Hope that makes sense; let me know if you have further questions. |
@MrMage I totally forgot to finish this, sorry. I've made the changes and created a test in But I can't see any testing target where I can run the test. ( Trying with SwiftGRPC-Carthage.xcodeproj ) Also I'm trying with |
Ok, I think cleaning the project helped. I can get some input with |
You should run |
At the end I needed to install |
I'm trying to test my grpc layer using
...ServiceTestStub
.If the rpc has a stream I can create all needed to test it. Also If the rpc doesn't have a stream but only if I use the synchronous method.
If I implement the asynchronous call I get an exception
fatalError("not implemented")
In the code generated for the stubs seems that there is not implementation for this type of method:
Do I have to create the stub manually to test this type of rpc's?
The text was updated successfully, but these errors were encountered: