[
https://issues.apache.org/jira/browse/BEAM-6825?focusedWorklogId=224736&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-224736
]
ASF GitHub Bot logged work on BEAM-6825:
----------------------------------------
Author: ASF GitHub Bot
Created on: 09/Apr/19 01:15
Start Date: 09/Apr/19 01:15
Worklog Time Spent: 10m
Work Description: lostluck commented on pull request #8243: [BEAM-6825]
Improve Combine error messages.
URL: https://github.com/apache/beam/pull/8243#discussion_r273293848
##########
File path: sdks/go/pkg/beam/core/graph/fn_test.go
##########
@@ -0,0 +1,297 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package graph
+
+import (
+ "context"
+ "reflect"
+ "testing"
+)
+
+func TestNewCombineFn(t *testing.T) {
+ t.Run("valid", func(t *testing.T) {
+ tests := []struct {
+ cfn interface{}
+ }{
+ {cfn: func(int, int) int { return 0 }},
+ {cfn: func(string, string) string { return "" }},
+ {cfn: func(MyAccum, MyAccum) MyAccum { return MyAccum{}
}},
+ {cfn: func(MyAccum, MyAccum) (MyAccum, error) { return
MyAccum{}, nil }},
+ {cfn: func(context.Context, MyAccum, MyAccum) MyAccum {
return MyAccum{} }},
+ {cfn: func(context.Context, MyAccum, MyAccum) (MyAccum,
error) { return MyAccum{}, nil }},
+ {cfn: &GoodCombineFn{}},
+ {cfn: &GoodWErrorCombineFn{}},
+ {cfn: &GoodWContextCombineFn{}},
+ {cfn: &GoodCombineFnUnexportedExtraMethod{}},
+ }
+
+ for _, test := range tests {
+ t.Run(reflect.TypeOf(test.cfn).String(), func(t
*testing.T) {
+ if _, err := NewCombineFn(test.cfn); err != nil
{
+ t.Fatalf("NewCombineFn failed: %v", err)
+ }
+ })
+ }
+ })
+ t.Run("invalid", func(t *testing.T) {
+ tests := []struct {
+ cfn interface{}
+ }{
+ // Validate MergeAccumulator errors
+ {cfn: func() int { return 0 }},
+ {cfn: func(int, int) {}},
+ {cfn: func(int, int) string { return "" }},
+ {cfn: func(string, string) int { return 0 }},
+ {cfn: func(int, string) int { return 0 }},
+ {cfn: func(string, int) int { return 0 }},
+ {cfn: func(string, int) (int, error) { return 0, nil }},
+ {cfn: &BadCombineFnNoMergeAccumulators{}},
+ {cfn: &BadCombineFnNonBinaryMergeAccumulators{}},
+ // Validate accumulator type mismatches
+ {cfn: &BadCombineFnMisMatchedCreateAccumulator{}},
+ {cfn: &BadCombineFnMisMatchedAddInputIn{}},
+ {cfn: &BadCombineFnMisMatchedAddInputOut{}},
+ {cfn: &BadCombineFnMisMatchedAddInputBoth{}},
+ {cfn: &BadCombineFnMisMatchedExtractOutput{}},
+ // Validate signatures
+ {cfn: &BadCombineFnInvalidCreateAccumulator1{}},
+ {cfn: &BadCombineFnInvalidCreateAccumulator2{}},
+ {cfn: &BadCombineFnInvalidCreateAccumulator3{}},
+ {cfn: &BadCombineFnInvalidCreateAccumulator4{}},
+ {cfn: &BadCombineFnInvalidAddInput1{}},
+ {cfn: &BadCombineFnInvalidAddInput2{}},
+ {cfn: &BadCombineFnInvalidAddInput3{}},
+ {cfn: &BadCombineFnInvalidAddInput4{}},
+ {cfn: &BadCombineFnInvalidExtractOutput1{}},
+ {cfn: &BadCombineFnInvalidExtractOutput2{}},
+ {cfn: &BadCombineFnInvalidExtractOutput3{}},
+ {cfn: &BadCombineFnExtraExportedMethod{}},
+ }
+ for _, test := range tests {
+ t.Run(reflect.TypeOf(test.cfn).String(), func(t
*testing.T) {
+ if cfn, err := NewCombineFn(test.cfn); err !=
nil {
+ // DO NOT SUBMIT make into a Logf once
errors are clear enough.
+ // Note to Developer: To work on
improving the error messages, use t.Errorf instead!
+ t.Logf("NewCombineFn failed as
expected:\n%v", err)
+ } else {
+ t.Errorf("AsCombineFn(%v) = %v, want
failure", cfn.Name(), cfn)
+ }
+ })
+ }
+ })
+}
+
+// Do not copy. The following types are for testing signatures only.
+// They are not working examples.
+type MyAccum struct{}
+
+type GoodCombineFn struct{}
Review comment:
I added a comment here and there to break up the sections, but it doesn't
add much or remove much. `go fmt` removes extra blank lines, and having empty
`// **** ` lines isn't common in Go.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 224736)
Time Spent: 50m (was: 40m)
> Improve pipeline construction time error messages in Go SDK.
> ------------------------------------------------------------
>
> Key: BEAM-6825
> URL: https://issues.apache.org/jira/browse/BEAM-6825
> Project: Beam
> Issue Type: New Feature
> Components: sdk-go
> Reporter: Daniel Oliveira
> Assignee: Daniel Oliveira
> Priority: Minor
> Labels: triaged
> Time Spent: 50m
> Remaining Estimate: 0h
>
> Many error messages for common pipeline construction mistakes are unclear and
> unhelpful. They need to be improved to provide more context, especially for
> newer users. This bug tracks these error message improvements.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)