-
Notifications
You must be signed in to change notification settings - Fork 75
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
chore(grpc-mock): restructure and add mock grpc tests #1579
base: main
Are you sure you want to change the base?
Conversation
.await | ||
.unwrap_err(); | ||
|
||
let rsp = client |
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.
I'd suggest doing let start = Instant::now();
just before this, and after the .await.unwrap()
below, you can assert that start.elapsed() >= const delay
.
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.
Same comment as above, but happy to put it in still if needed
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.
I'd prefer to not change this file because it's taken from a well known service.
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.
Reverted in 4b15aa0, but needed a type with more fields to adequately test message_partial_pbjson
so I added a new struct MockMessage
to test_utils
. Let me know if this works for you!
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.
I didn't mean for you to implement this manually (although I am sure it was a good exercise to learn about prost and manual serde impls).
What if you you copy the echo server over (from here: https://github.com/hyperium/tonic/blob/master/examples/proto/echo/echo.proto) and just generate extra code?
That way we don't have to worry about potential breakage should we ever update prost or tonic.
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.
This is looking good. I would not do the manual the manual mock message - just because we might end up in a situation where we bump either of prost, tonic, or pbjson, subtly breaking the derived code.
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.
I didn't mean for you to implement this manually (although I am sure it was a good exercise to learn about prost and manual serde impls).
What if you you copy the echo server over (from here: https://github.com/hyperium/tonic/blob/master/examples/proto/echo/echo.proto) and just generate extra code?
That way we don't have to worry about potential breakage should we ever update prost or tonic.
@@ -1,3 +1,4 @@ | |||
// This file is @generated by prost-build. |
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.
Was this added by you or by prost?
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.
Added by prost, I think at some point I may have bumped the dep and this is a new thing that the builder does? If I remember correctly, I believe I've noticed it elsewhere as well.
@SuperFluffy in RE to the comment ^^above (since I can't reply directly), I'm not sure the echo server would be sufficient as is. To adequately test the |
Summary
Divided GRPC mock tests by component and added a few more.
Background
Some parts of the GRPC mock still weren't tested, and the crate also needed a test for the new delay capabilities.
Changes
mock
,response
, andmatcher
.HealthCheckRequest
so that we could more accurately testmatcher::partialpbjson
.and
mock combinator, matchers not matching incorrect requests,up_to_n_times
,DynamicResponse
, and delay.Testing
All tests passing.
Related Issues
closes #902
closes #1559