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/07/06 20:00:25 UTC

[GitHub] [beam] lnogueir commented on a diff in pull request #22152: Add fhirio.Deidentify transform

lnogueir commented on code in PR #22152:
URL: https://github.com/apache/beam/pull/22152#discussion_r915208175


##########
sdks/go/pkg/beam/io/fhirio/utils_test.go:
##########
@@ -118,19 +127,23 @@ func (m *fakeReaderCloser) Read(b []byte) (int, error) {
 	return m.fakeRead(b)
 }
 
-func validateCounter(pipelineResult beam.PipelineResult, expectedCounterName string, expectedCount int) error {
-	counterResults := pipelineResult.Metrics().AllMetrics().Counters()
-	if len(counterResults) != 1 {
-		return fmt.Errorf("counterResults got length %v, expected %v", len(counterResults), 1)
+func validateCounter(t *testing.T, pipelineResult beam.PipelineResult, expectedCounterName string, expectedCount int) {
+	t.Helper()
+
+	counterResults := pipelineResult.Metrics().Query(func(mr beam.MetricResult) bool {
+		return mr.Name() == expectedCounterName
+	}).Counters()
+
+	if expectedCount == 0 && len(counterResults) == 0 {
+		return
 	}
-	counterResult := counterResults[0]
 
-	if counterResult.Name() != expectedCounterName {
-		return fmt.Errorf("counterResult.Name() is '%v', expected '%v'", counterResult.Name(), expectedCounterName)
+	if len(counterResults) != 1 {
+		t.Fatalf("counter %v got length %v, expected %v", expectedCounterName, len(counterResults), 1)

Review Comment:
   That's true. Fixed.



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