[ 
https://issues.apache.org/jira/browse/BEAM-13886?focusedWorklogId=732505&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-732505
 ]

ASF GitHub Bot logged work on BEAM-13886:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Feb/22 17:11
            Start Date: 24/Feb/22 17:11
    Worklog Time Spent: 10m 
      Work Description: 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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 732505)
    Time Spent: 1h  (was: 50m)

> Add unit testing to the trigger package
> ---------------------------------------
>
>                 Key: BEAM-13886
>                 URL: https://issues.apache.org/jira/browse/BEAM-13886
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-go
>            Reporter: Jack McCluskey
>            Assignee: Ritesh Ghorse
>            Priority: P2
>              Labels: starter
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Add basic unit testing to the [trigger 
> package|https://github.com/apache/beam/tree/release-2.36.0/sdks/go/pkg/beam/core/graph/window/trigger]
> We want code coverage at or above 50%, it is currently at 0%.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to