damccorm commented on a change in pull request #16935:
URL: https://github.com/apache/beam/pull/16935#discussion_r814090161



##########
File path: sdks/go/pkg/beam/core/graph/window/trigger/trigger_test.go
##########
@@ -0,0 +1,59 @@
+// 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 trigger
+
+import (
+       "testing"
+       "time"
+)
+
+func TestAfterCount(t *testing.T) {
+       tr := AfterCount(1)
+       want := int32(1)
+       if got := tr.ElementCount(); got != want {
+               t.Errorf("element count not configured correctly. got %v, want 
%v", got, want)
+       }
+}
+
+func TestAfterProcessingTime(t *testing.T) {

Review comment:
       I think this is actually more testing the full behavior of 
AfterProcessingTimeTrigger, so I'd probably update to 
`TestAfterProcessingTimeTrigger`

##########
File path: sdks/go/pkg/beam/core/graph/window/trigger/trigger_test.go
##########
@@ -0,0 +1,59 @@
+// 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 trigger
+
+import (
+       "testing"
+       "time"
+)
+
+func TestAfterCount(t *testing.T) {
+       tr := AfterCount(1)
+       want := int32(1)
+       if got := tr.ElementCount(); got != want {
+               t.Errorf("element count not configured correctly. got %v, want 
%v", got, want)
+       }
+}
+
+func TestAfterProcessingTime(t *testing.T) {
+       tr := AfterProcessingTime()
+       tr.PlusDelay(time.Millisecond).AlignedTo(time.Millisecond, time.Now())
+       want := 2
+       if got := len(tr.TimestampTransforms()); got != want {
+               t.Errorf("timestamp transforms not configured correctly. got 
%v, want %v", got, want)
+       }
+}
+
+func TestRepeat(t *testing.T) {
+       subTr := AfterCount(1)
+       tr := Repeat(subTr)
+
+       if got := tr.SubTrigger(); got != subTr {
+               t.Errorf("subtrigger not configured correctly. got %v, want 
%v", got, subTr)
+       }
+}
+
+func TestAfterEndOfWindow(t *testing.T) {

Review comment:
       Same comment about naming - could we name this 
TestAfterEndOfWindowTrigger?

##########
File path: sdks/go/pkg/beam/core/graph/window/trigger/trigger_test.go
##########
@@ -0,0 +1,59 @@
+// 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 trigger
+
+import (
+       "testing"
+       "time"
+)
+
+func TestAfterCount(t *testing.T) {
+       tr := AfterCount(1)
+       want := int32(1)
+       if got := tr.ElementCount(); got != want {
+               t.Errorf("element count not configured correctly. got %v, want 
%v", got, want)
+       }
+}
+
+func TestAfterProcessingTime(t *testing.T) {
+       tr := AfterProcessingTime()
+       tr.PlusDelay(time.Millisecond).AlignedTo(time.Millisecond, time.Now())
+       want := 2
+       if got := len(tr.TimestampTransforms()); got != want {
+               t.Errorf("timestamp transforms not configured correctly. got 
%v, want %v", got, want)
+       }

Review comment:
       Could we verify that the transforms are actually correct as well? e.g. 
that the first one is a DelayTransform with delay of 1 and the second one is an 
AlignToTransform with the correct values as well

##########
File path: sdks/go/pkg/beam/core/graph/window/trigger/trigger_test.go
##########
@@ -0,0 +1,59 @@
+// 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 trigger
+
+import (
+       "testing"
+       "time"
+)
+
+func TestAfterCount(t *testing.T) {
+       tr := AfterCount(1)
+       want := int32(1)
+       if got := tr.ElementCount(); got != want {
+               t.Errorf("element count not configured correctly. got %v, want 
%v", got, want)
+       }
+}
+
+func TestAfterProcessingTime(t *testing.T) {
+       tr := AfterProcessingTime()
+       tr.PlusDelay(time.Millisecond).AlignedTo(time.Millisecond, time.Now())
+       want := 2
+       if got := len(tr.TimestampTransforms()); got != want {
+               t.Errorf("timestamp transforms not configured correctly. got 
%v, want %v", got, want)
+       }
+}
+
+func TestRepeat(t *testing.T) {
+       subTr := AfterCount(1)
+       tr := Repeat(subTr)
+
+       if got := tr.SubTrigger(); got != subTr {
+               t.Errorf("subtrigger not configured correctly. got %v, want 
%v", got, subTr)
+       }
+}
+
+func TestAfterEndOfWindow(t *testing.T) {

Review comment:
       Normally I'd push to separate testing different functions in different 
tests, but things are so simple here that I don't think we need that




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