[BEAM-12548] Add examples of Equals and EqualsList to equals_test.go#15112
[BEAM-12548] Add examples of Equals and EqualsList to equals_test.go#15112lostluck merged 3 commits intoapache:masterfrom
Conversation
|
R: @lostluck |
|
Run GoPortable PreCommit |
lostluck
left a comment
There was a problem hiding this comment.
One comnment! Thanks! This will make things much clearer.
| if wrapper, ok := err.(interface{ Unwrap() error }); ok { | ||
| err = wrapper.Unwrap() | ||
| } |
There was a problem hiding this comment.
Consider hiding this in a helper method.
err = unwrapError(err)
Unnecessary details can detract from an example's utility.
…wrapping the error
|
|
||
| func unwrapError(err error) error { | ||
| if wrapper, ok := err.(interface{ Unwrap() error}); ok { | ||
| err = wrapper.Unwrap() |
There was a problem hiding this comment.
Style wise, idiomatic go tends to just return early as needed, rather than trying for a single return.
Nothing wrong with the approach, and doesn't make a difference here but good to know.
There was a problem hiding this comment.
Changed just to start building that habit.
| EqualsList(s, col, list) | ||
| err := ptest.Run(p) | ||
| err = unwrapError(err) | ||
| fmt.Println(err.Error()) |
There was a problem hiding this comment.
It's not required to call the error message, the fmt.Print* functions are smart enough to pull out the .Error() themselves.
There was a problem hiding this comment.
Changed for cleanliness
Adds examples of the usages of Equals and EqualsList functions to equals_test.go. Covers successful usages with individual expected values, a PCollection of values, and an array/slice of values. Also shows the expected error message on a mismatch.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username).[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
ValidatesRunnercompliance status (on master branch)Examples testing status on various runners
Post-Commit SDK/Transform Integration Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.