[
https://issues.apache.org/jira/browse/BEAM-12548?focusedWorklogId=617778&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-617778
]
ASF GitHub Bot logged work on BEAM-12548:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 01/Jul/21 19:33
Start Date: 01/Jul/21 19:33
Worklog Time Spent: 10m
Work Description: lostluck commented on a change in pull request #15112:
URL: https://github.com/apache/beam/pull/15112#discussion_r662543358
##########
File path: sdks/go/pkg/beam/testing/passert/equals_test.go
##########
@@ -130,3 +131,69 @@ func TestEqualsList_Bad(t *testing.T) {
}
}
}
+
+func ExampleEquals() {
+ p, s := beam.NewPipelineWithRoot()
+ col := beam.Create(s, "some", "example", "strings")
+
+ Equals(s, col, "example", "some", "strings")
+ err := ptest.Run(p)
+ fmt.Println(err == nil)
+
+ // Output: true
+}
+
+func ExampleEquals_pcollection() {
+ p, s := beam.NewPipelineWithRoot()
+ col := beam.Create(s, "some", "example", "strings")
+ exp := beam.Create(s, "example", "some", "strings")
+
+ Equals(s, col, exp)
+ err := ptest.Run(p)
+ fmt.Println(err == nil)
+
+ // Output: true
+}
+
+func ExampleEqualsList() {
+ p, s := beam.NewPipelineWithRoot()
+ col := beam.Create(s, "example", "inputs", "here")
+ list := [3]string{"here", "example", "inputs"}
+
+ EqualsList(s, col, list)
+ err := ptest.Run(p)
+ fmt.Println(err == nil)
+
+ // Output: true
+}
+
+func unwrapError(err error) error {
+ if wrapper, ok := err.(interface{ Unwrap() error}); ok {
+ err = wrapper.Unwrap()
+ }
+ return err
+}
+
+func ExampleEqualsList_mismatch() {
+ p, s := beam.NewPipelineWithRoot()
+ col := beam.Create(s, "example", "inputs", "here")
+ list := [3]string{"wrong", "inputs", "here"}
+
+ EqualsList(s, col, list)
+ err := ptest.Run(p)
+ err = unwrapError(err)
+ fmt.Println(err.Error())
Review comment:
It's not required to call the error message, the fmt.Print* functions
are smart enough to pull out the .Error() themselves.
##########
File path: sdks/go/pkg/beam/testing/passert/equals_test.go
##########
@@ -130,3 +131,69 @@ func TestEqualsList_Bad(t *testing.T) {
}
}
}
+
+func ExampleEquals() {
+ p, s := beam.NewPipelineWithRoot()
+ col := beam.Create(s, "some", "example", "strings")
+
+ Equals(s, col, "example", "some", "strings")
+ err := ptest.Run(p)
+ fmt.Println(err == nil)
+
+ // Output: true
+}
+
+func ExampleEquals_pcollection() {
+ p, s := beam.NewPipelineWithRoot()
+ col := beam.Create(s, "some", "example", "strings")
+ exp := beam.Create(s, "example", "some", "strings")
+
+ Equals(s, col, exp)
+ err := ptest.Run(p)
+ fmt.Println(err == nil)
+
+ // Output: true
+}
+
+func ExampleEqualsList() {
+ p, s := beam.NewPipelineWithRoot()
+ col := beam.Create(s, "example", "inputs", "here")
+ list := [3]string{"here", "example", "inputs"}
+
+ EqualsList(s, col, list)
+ err := ptest.Run(p)
+ fmt.Println(err == nil)
+
+ // Output: true
+}
+
+func unwrapError(err error) error {
+ if wrapper, ok := err.(interface{ Unwrap() error}); ok {
+ err = wrapper.Unwrap()
Review 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 617778)
Time Spent: 2h 10m (was: 2h)
> [Go SDK] PAssert improvements
> -----------------------------
>
> Key: BEAM-12548
> URL: https://issues.apache.org/jira/browse/BEAM-12548
> Project: Beam
> Issue Type: Improvement
> Components: sdk-go
> Reporter: Robert Burke
> Assignee: Jack McCluskey
> Priority: P2
> Time Spent: 2h 10m
> Remaining Estimate: 0h
>
> The Go SDK Passert package could be more helpful.
> It could haveĀ GoDoc examples for correct and less clear use of each of the
> functions (like both the variadic and PCollection approaches forĀ
> passert.Equals).
> There could be better/more sophisticated handling for floating point values,
> eg with thresholds.
> There could be special/magic handling for synthetic KV types that could then
> be used for handling Equals against KV PCollections.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)