lostluck commented on a change in pull request #16629:
URL: https://github.com/apache/beam/pull/16629#discussion_r797973774



##########
File path: sdks/go/pkg/beam/core/funcx/fn_test.go
##########
@@ -291,6 +301,96 @@ func TestEmits(t *testing.T) {
        }
 }
 
+func TestPane(t *testing.T) {
+       tests := []struct {
+               Name   string
+               Params []FnParamKind
+               Pos    int
+               Exists bool
+       }{
+               {
+                       Name:   "pane input",
+                       Params: []FnParamKind{FnContext, FnPane},
+                       Pos:    1,
+                       Exists: true,
+               },
+               {
+                       Name:   "no pane input",
+                       Params: []FnParamKind{FnContext, FnEventTime},
+                       Pos:    -1,
+                       Exists: false,
+               },
+       }
+
+       for _, test := range tests {
+               test := test
+               t.Run(test.Name, func(t *testing.T) {
+                       // Create a Fn with a filled params list.
+                       params := make([]FnParam, len(test.Params))
+                       for i, kind := range test.Params {
+                               params[i].Kind = kind
+                               params[i].T = nil
+                       }
+                       fn := new(Fn)
+                       fn.Param = params

Review comment:
       It's in very rare circumstances where one calls "new" for idiomatic go, 
to get a pointer value.
   ```suggestion
                        fn := &Fn{Params: params}
   ```

##########
File path: sdks/go/test/integration/integration.go
##########
@@ -61,9 +61,10 @@ var directFilters = []string{
        // The direct runner does not yet support cross-language.
        "TestXLang.*",
        "TestKafkaIO.*",
-       "TestJDBCIO_BasicReadWrite",
-       // Triggers are not yet supported
+  "TestJDBCIO_BasicReadWrite",

Review comment:
       We lost the tab here.

##########
File path: sdks/go/pkg/beam/core/funcx/fn_test.go
##########
@@ -291,6 +301,96 @@ func TestEmits(t *testing.T) {
        }
 }
 
+func TestPane(t *testing.T) {
+       tests := []struct {
+               Name   string
+               Params []FnParamKind
+               Pos    int
+               Exists bool
+       }{
+               {
+                       Name:   "pane input",
+                       Params: []FnParamKind{FnContext, FnPane},
+                       Pos:    1,
+                       Exists: true,
+               },
+               {
+                       Name:   "no pane input",
+                       Params: []FnParamKind{FnContext, FnEventTime},
+                       Pos:    -1,
+                       Exists: false,
+               },
+       }
+
+       for _, test := range tests {
+               test := test
+               t.Run(test.Name, func(t *testing.T) {
+                       // Create a Fn with a filled params list.
+                       params := make([]FnParam, len(test.Params))
+                       for i, kind := range test.Params {
+                               params[i].Kind = kind
+                               params[i].T = nil
+                       }
+                       fn := new(Fn)
+                       fn.Param = params
+
+                       // Validate we get expected results for pane function.
+                       pos, exists := fn.Pane()
+                       if exists != test.Exists {
+                               t.Errorf("Pane(%v) - exists: got %v, want %v", 
params, exists, test.Exists)
+                       }
+                       if pos != test.Pos {
+                               t.Errorf("Pane(%v) - pos: got %v, want %v", 
params, pos, test.Pos)
+                       }
+               })
+       }
+}
+
+func TestWindow(t *testing.T) {
+       tests := []struct {
+               Name   string
+               Params []FnParamKind
+               Pos    int
+               Exists bool
+       }{
+               {
+                       Name:   "window input",
+                       Params: []FnParamKind{FnContext, FnWindow},
+                       Pos:    1,
+                       Exists: true,
+               },
+               {
+                       Name:   "no window input",
+                       Params: []FnParamKind{FnContext, FnEventTime},
+                       Pos:    -1,
+                       Exists: false,
+               },
+       }
+
+       for _, test := range tests {
+               test := test
+               t.Run(test.Name, func(t *testing.T) {
+                       // Create a Fn with a filled params list.
+                       params := make([]FnParam, len(test.Params))
+                       for i, kind := range test.Params {
+                               params[i].Kind = kind
+                               params[i].T = nil
+                       }
+                       fn := new(Fn)
+                       fn.Param = params

Review comment:
       Same here,




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