Skip to content
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

tests: refactor tests to use testutils helper functions #5728

Merged
merged 4 commits into from Oct 19, 2022

Conversation

arvindbr8
Copy link
Member

@arvindbr8 arvindbr8 commented Oct 18, 2022

As a reactive from a previous PR (#5711) we want to update certain tests to use helper functions from internal/testutils/balancer.go

RELEASE NOTES: n/a

@arvindbr8 arvindbr8 added the Type: Internal Cleanup Refactors, etc label Oct 18, 2022
@arvindbr8 arvindbr8 added this to the 1.51 Release milestone Oct 18, 2022
@arvindbr8 arvindbr8 changed the title use reflect.DeepEqual for error check in tests tests: refactor tests to use testutils helper functions Oct 18, 2022
@arvindbr8 arvindbr8 assigned arvindbr8 and easwars and unassigned easwars and arvindbr8 Oct 18, 2022
internal/testutils/balancer.go Outdated Show resolved Hide resolved
balancer/weightedtarget/weightedtarget_test.go Outdated Show resolved Hide resolved
balancer/weightedtarget/weightedtarget_test.go Outdated Show resolved Hide resolved
balancer/weightedtarget/weightedtarget_test.go Outdated Show resolved Hide resolved
balancer/weightedtarget/weightedtarget_test.go Outdated Show resolved Hide resolved
xds/internal/balancer/clusterresolver/priority_test.go Outdated Show resolved Hide resolved
xds/internal/balancer/clusterresolver/priority_test.go Outdated Show resolved Hide resolved
xds/internal/balancer/clusterresolver/priority_test.go Outdated Show resolved Hide resolved
xds/internal/balancer/clusterresolver/priority_test.go Outdated Show resolved Hide resolved
xds/internal/balancer/clusterresolver/priority_test.go Outdated Show resolved Hide resolved
@easwars easwars assigned arvindbr8 and unassigned easwars Oct 19, 2022
return func(p balancer.Picker) error {
for i := 0; i < rpcCount; i++ {
if _, err := p.Pick(balancer.PickInfo{}); err == nil || !strings.Contains(err.Error(), want.Error()) {
return fmt.Errorf("got %q, want error to contain %q, ", want, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention that the error was returned from Pick. See go/go-style/decisions#identify-the-function

return fmt.Errorf("Pick() returned error: %v, want: %v", err, want)

We usually use %v as the formatting directive for error types. If you feel strongly about using %q, then I don't mind. But otherwise, it would be better to stick to %v.

Also note that you have for the order or got and want wrong in the arguments list passed to fmt.Error.

Copy link
Member Author

Choose a reason for hiding this comment

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

thats a good catch. updating the error message and also flipping the args around

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for catching that. updating this

balancer/weightedtarget/weightedtarget_test.go Outdated Show resolved Hide resolved
balancer/weightedtarget/weightedtarget_test.go Outdated Show resolved Hide resolved
@easwars easwars assigned arvindbr8 and unassigned easwars Oct 19, 2022
@arvindbr8 arvindbr8 assigned easwars and unassigned arvindbr8 Oct 19, 2022
@easwars easwars assigned arvindbr8 and unassigned easwars Oct 19, 2022
@arvindbr8 arvindbr8 merged commit 7c16802 into grpc:master Oct 19, 2022
1 check passed
@arvindbr8 arvindbr8 deleted the deep-equal-for-error branch January 24, 2023 20:08
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants