@@ -22,7 +22,6 @@ package internal
2222
2323import (
2424 "context"
25- "fmt"
2625 "testing"
2726
2827 "github.com/golang/mock/gomock"
@@ -54,46 +53,41 @@ func (s *activityTestSuite) TearDownTest() {
5453 s .mockCtrl .Finish () // assert mock’s expectations
5554}
5655
57- // this is the mock for yarpcCallOptions, make sure length are the same
58- var callOptions = []interface {}{gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()}
59-
60- var featureFlags = FeatureFlags {}
61-
6256func (s * activityTestSuite ) TestActivityHeartbeat () {
6357 ctx , cancel := context .WithCancel (context .Background ())
64- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), featureFlags )
58+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {} )
6559 ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {serviceInvoker : invoker })
6660
67- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
61+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
6862 Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
6963
7064 RecordActivityHeartbeat (ctx , "testDetails" )
7165}
7266
7367func (s * activityTestSuite ) TestActivityHeartbeat_InternalError () {
7468 ctx , cancel := context .WithCancel (context .Background ())
75- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), featureFlags )
69+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {} )
7670 ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
7771 serviceInvoker : invoker ,
7872 logger : getTestLogger (s .T ())})
7973
80- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
74+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
8175 Return (nil , & shared.InternalServiceError {}).
8276 Do (func (ctx context.Context , request * shared.RecordActivityTaskHeartbeatRequest , opts ... yarpc.CallOption ) {
83- fmt . Println ("MOCK RecordActivityTaskHeartbeat executed" )
77+ s . T (). Log ("MOCK RecordActivityTaskHeartbeat executed" )
8478 }).AnyTimes ()
8579
8680 RecordActivityHeartbeat (ctx , "testDetails" )
8781}
8882
8983func (s * activityTestSuite ) TestActivityHeartbeat_CancelRequested () {
9084 ctx , cancel := context .WithCancel (context .Background ())
91- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), featureFlags )
85+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {} )
9286 ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
9387 serviceInvoker : invoker ,
9488 logger : getTestLogger (s .T ())})
9589
96- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
90+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
9791 Return (& shared.RecordActivityTaskHeartbeatResponse {CancelRequested : common .BoolPtr (true )}, nil ).Times (1 )
9892
9993 RecordActivityHeartbeat (ctx , "testDetails" )
@@ -103,12 +97,12 @@ func (s *activityTestSuite) TestActivityHeartbeat_CancelRequested() {
10397
10498func (s * activityTestSuite ) TestActivityHeartbeat_EntityNotExist () {
10599 ctx , cancel := context .WithCancel (context .Background ())
106- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), featureFlags )
100+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {} )
107101 ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
108102 serviceInvoker : invoker ,
109103 logger : getTestLogger (s .T ())})
110104
111- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
105+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
112106 Return (& shared.RecordActivityTaskHeartbeatResponse {}, & shared.EntityNotExistsError {}).Times (1 )
113107
114108 RecordActivityHeartbeat (ctx , "testDetails" )
@@ -118,13 +112,13 @@ func (s *activityTestSuite) TestActivityHeartbeat_EntityNotExist() {
118112
119113func (s * activityTestSuite ) TestActivityHeartbeat_SuppressContinousInvokes () {
120114 ctx , cancel := context .WithCancel (context .Background ())
121- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 2 , make (chan struct {}), featureFlags )
115+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 2 , make (chan struct {}), FeatureFlags {} )
122116 ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
123117 serviceInvoker : invoker ,
124118 logger : getTestLogger (s .T ())})
125119
126120 // Multiple calls but only one call is made.
127- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
121+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
128122 Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
129123 RecordActivityHeartbeat (ctx , "testDetails" )
130124 RecordActivityHeartbeat (ctx , "testDetails" )
@@ -133,11 +127,11 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
133127
134128 // No HB timeout configured.
135129 service2 := workflowservicetest .NewMockClient (s .mockCtrl )
136- invoker2 := newServiceInvoker ([]byte ("task-token" ), "identity" , service2 , cancel , 0 , make (chan struct {}), featureFlags )
130+ invoker2 := newServiceInvoker ([]byte ("task-token" ), "identity" , service2 , cancel , 0 , make (chan struct {}), FeatureFlags {} )
137131 ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
138132 serviceInvoker : invoker2 ,
139133 logger : getTestLogger (s .T ())})
140- service2 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
134+ service2 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
141135 Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
142136 RecordActivityHeartbeat (ctx , "testDetails" )
143137 RecordActivityHeartbeat (ctx , "testDetails" )
@@ -146,14 +140,14 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
146140 // simulate batch picks before expiry.
147141 waitCh := make (chan struct {})
148142 service3 := workflowservicetest .NewMockClient (s .mockCtrl )
149- invoker3 := newServiceInvoker ([]byte ("task-token" ), "identity" , service3 , cancel , 2 , make (chan struct {}), featureFlags )
143+ invoker3 := newServiceInvoker ([]byte ("task-token" ), "identity" , service3 , cancel , 2 , make (chan struct {}), FeatureFlags {} )
150144 ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
151145 serviceInvoker : invoker3 ,
152146 logger : getTestLogger (s .T ())})
153- service3 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
147+ service3 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
154148 Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
155149
156- service3 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
150+ service3 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
157151 Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).
158152 Do (func (ctx context.Context , request * shared.RecordActivityTaskHeartbeatRequest , opts ... yarpc.CallOption ) {
159153 ev := newEncodedValues (request .Details , nil )
@@ -176,13 +170,13 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
176170 // simulate batch picks before expiry, with out any progress specified.
177171 waitCh2 := make (chan struct {})
178172 service4 := workflowservicetest .NewMockClient (s .mockCtrl )
179- invoker4 := newServiceInvoker ([]byte ("task-token" ), "identity" , service4 , cancel , 2 , make (chan struct {}), featureFlags )
173+ invoker4 := newServiceInvoker ([]byte ("task-token" ), "identity" , service4 , cancel , 2 , make (chan struct {}), FeatureFlags {} )
180174 ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
181175 serviceInvoker : invoker4 ,
182176 logger : getTestLogger (s .T ())})
183- service4 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
177+ service4 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
184178 Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
185- service4 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
179+ service4 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
186180 Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).
187181 Do (func (ctx context.Context , request * shared.RecordActivityTaskHeartbeatRequest , opts ... yarpc.CallOption ) {
188182 require .Nil (s .T (), request .Details )
@@ -200,14 +194,14 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
200194func (s * activityTestSuite ) TestActivityHeartbeat_WorkerStop () {
201195 ctx , cancel := context .WithCancel (context .Background ())
202196 workerStopChannel := make (chan struct {})
203- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 5 , workerStopChannel , featureFlags )
197+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 5 , workerStopChannel , FeatureFlags {} )
204198 ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {serviceInvoker : invoker })
205199
206200 heartBeatDetail := "testDetails"
207201 waitCh := make (chan struct {}, 1 )
208202 waitCh <- struct {}{}
209203 waitC2 := make (chan struct {}, 1 )
210- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
204+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
211205 Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).
212206 Do (func (ctx context.Context , request * shared.RecordActivityTaskHeartbeatRequest , opts ... yarpc.CallOption ) {
213207 if _ , ok := <- waitCh ; ok {
0 commit comments