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]


Reply via email to