You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/07/01 19:16:51 UTC

[GitHub] [beam] lostluck commented on a change in pull request #15112: [BEAM-12548] Add examples of Equals and EqualsList to equals_test.go

lostluck commented on a change in pull request #15112:
URL: https://github.com/apache/beam/pull/15112#discussion_r662533411



##########
File path: sdks/go/pkg/beam/testing/passert/equals_test.go
##########
@@ -130,3 +131,64 @@ 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 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)
+	if wrapper, ok := err.(interface{ Unwrap() error }); ok {
+		err = wrapper.Unwrap()
+	}

Review comment:
       Consider hiding this in a helper method.  
   
   `err = unwrapError(err)`
   
   Unnecessary details can detract from an example's utility.




-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org