-
Notifications
You must be signed in to change notification settings - Fork 812
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
add unit test for history client #5841
add unit test for history client #5841
Conversation
Pull Request Test Coverage Report for Build 018ea086-5071-4f5f-8be5-0c42f9c6dc5cDetails
💛 - Coveralls |
numberOfShards int | ||
resolver membership.Resolver | ||
namedPort string // grpc or tchannel, depends on yarpc configuration | ||
} | ||
|
||
// NewPeerResolver creates a new history peer resolver. | ||
func NewPeerResolver(numberOfShards int, resolver membership.Resolver, namedPort string) PeerResolver { | ||
return PeerResolver{ | ||
return peerResolver{ |
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.
let's change this to &peerResolver
and attach the functions to the *peerResolver
@@ -29,15 +29,25 @@ import ( | |||
// PeerResolver is used to resolve history peers. | |||
// Those are deployed instances of Cadence history services that participate in the cluster ring. | |||
// The resulting peer is simply an address of form ip:port where RPC calls can be routed to. | |||
type PeerResolver struct { | |||
// | |||
//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination peerResolver_mock.go -package history github.com/uber/cadence/client/history PeerResolver |
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.
please rename this file to peer_resolver.go and the mock file to peer_resolver_test.go. we keep fixing naming inconsistencies as we touch
}) | ||
}, | ||
mock: func(p *MockPeerResolver, c *MockClient) { | ||
p.EXPECT().FromShardID(123).Return("test-peer", nil).Times(1) |
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.
let's add more test cases to cover
- peerResolver's corresponding method returning err causes client method to return err
- mock client's corresponding method returning err causes client method to return err
otherwise there are plenty of code branches uncovered. https://app.codecov.io/github/uber/cadence/commit/eaacb01073f6fc3c844329d557b732f3102cc41b/blob/client/history/client.go
What changed?
Why?
improve test coverage
How did you test it?
Potential risks
Release notes
Documentation Changes