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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]