lostluck commented on code in PR #17790:
URL: https://github.com/apache/beam/pull/17790#discussion_r887129346


##########
sdks/go/pkg/beam/core/graph/fn_test.go:
##########
@@ -378,6 +380,129 @@ func TestNewCombineFn(t *testing.T) {
        })
 }
 
+func TestNewFn_DoFn(t *testing.T) {
+       // Validate wrap fallthrough
+       reflectx.RegisterStructWrapper(reflect.TypeOf((*GoodDoFn)(nil)).Elem(), 
func(fn interface{}) map[string]reflectx.Func {
+               gdf := fn.(*GoodDoFn)
+               return map[string]reflectx.Func{
+                       processElementName: reflectx.MakeFunc1x1(func(v int) 
int {
+                               return gdf.ProcessElement(v)
+                       }),
+               }
+       })
+
+       userFn := &GoodDoFn{}
+       fn, err := NewFn(userFn)
+       if err != nil {
+               t.Errorf("NewFn(%T) failed:\n%v", userFn, err)
+       }
+       dofn, err := AsDoFn(fn, MainSingle)
+       if err != nil {
+               t.Errorf("AsDoFn(%v, MainSingle) failed:\n%v", fn.Name(), err)
+       }
+       // Check that we get expected values for all the methods.
+       if got, want := dofn.Name(), "GoodDoFn"; !strings.HasSuffix(got, want) {
+               t.Errorf("(%v).Name() = %q, want suffix %q", dofn.Name(), got, 
want)
+       }
+       if dofn.SetupFn() == nil {
+               t.Errorf("(%v).SetupFn() == nil, want value", dofn.Name())
+       }
+       if dofn.StartBundleFn() == nil {
+               t.Errorf("(%v).StartBundleFn() == nil, want value", dofn.Name())
+       }
+       if dofn.ProcessElementFn() == nil {
+               t.Errorf("(%v).ProcessElementFn() == nil, want value", 
dofn.Name())
+       }
+       if dofn.FinishBundleFn() == nil {
+               t.Errorf("(%v).FinishBundleFn() == nil, want value", 
dofn.Name())
+       }
+       if dofn.TeardownFn() == nil {
+               t.Errorf("(%v).TeardownFn() == nil, want value", dofn.Name())
+       }
+       if dofn.IsSplittable() {
+               t.Errorf("(%v).IsSplittable() = true, want false", dofn.Name())
+       }
+}
+
+func TestNewFn_SplittableDoFn(t *testing.T) {

Review Comment:
   Ah, I knew I missed something. Thank you!
   
   We also have a vestigial "CompactFn" It's intended to allow CombineFns to do 
compression of the accumulators, but it seems it's not documented or called 
anywhere. Out of scope to delete it in this PR, but it could be worth 
implementing for user use eventually.



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

Reply via email to