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 2022/06/02 16:14:17 UTC

[GitHub] [beam] msbukal commented on a diff in pull request #17803: [BEAM-14532] Add integration testing to fhirio Read transform

msbukal commented on code in PR #17803:
URL: https://github.com/apache/beam/pull/17803#discussion_r888142695


##########
sdks/go/test/integration/io/fhirio/fhirio.go:
##########
@@ -0,0 +1,30 @@
+package fhirio
+
+import (
+	"strings"
+
+	"github.com/apache/beam/sdks/v2/go/pkg/beam"
+	"github.com/apache/beam/sdks/v2/go/pkg/beam/io/fhirio"
+	"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/passert"
+	"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/ptest"
+)
+
+func ReadPipeline(testResourcePaths []string) *beam.Pipeline {

Review Comment:
   Go style usually actively disapproves of running test logic in a separate, non-test method. Is there a reason you do a pattern like this? 
   
   Otherwise it should just go in TestRead_*



##########
sdks/go/pkg/beam/io/fhirio/read_test.go:
##########
@@ -76,15 +76,20 @@ func TestRead(t *testing.T) {
 			})
 			pipelineResult := ptest.RunAndValidate(t, p)
 			counterResults := pipelineResult.Metrics().AllMetrics().Counters()
-			if len(counterResults) != 1 {
-				t.Fatal("Only one counter should have been used")
-			}
-			if counterResults[0].Name() != "fhirio/read_resource_error_count" {
-				t.Fatal("Only error counter should have been used")
-			}
-			if counterResults[0].Result() != int64(len(testResourcePaths)) {
-				t.Fatal("Counter should have been incremented by the number of test resource paths")
+			if counterResult := counterResults[0]; len(counterResults) == 1 {

Review Comment:
   go style is more like the left, you can just move up the assignment like
   
   ```
   counterResult := counterResults[0]
   if len(counterResults) != 1 {
       t.Fatalf(...)
   }
   [other validation]
   ```



-- 
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