Skip to content

Commit 89a59a7

Browse files
committed
[Access] Fix mocking in connection unittests
1 parent 088596f commit 89a59a7

File tree

1 file changed

+52
-11
lines changed

1 file changed

+52
-11
lines changed

engine/access/rpc/connection/connection_test.go

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ func TestProxyAccessAPI(t *testing.T) {
4040

4141
req := &access.PingRequest{}
4242
expected := &access.PingResponse{}
43-
cn.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
43+
cn.handler.
44+
On("Ping",
45+
testifymock.Anything,
46+
testifymock.AnythingOfType("*access.PingRequest")).
47+
Return(expected, nil)
4448

4549
// create the factory
4650
connectionFactory := new(ConnectionFactoryImpl)
@@ -85,7 +89,11 @@ func TestProxyExecutionAPI(t *testing.T) {
8589

8690
req := &execution.PingRequest{}
8791
expected := &execution.PingResponse{}
88-
en.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
92+
en.handler.
93+
On("Ping",
94+
testifymock.Anything,
95+
testifymock.AnythingOfType("*access.PingRequest")).
96+
Return(expected, nil)
8997

9098
// create the factory
9199
connectionFactory := new(ConnectionFactoryImpl)
@@ -130,7 +138,11 @@ func TestProxyAccessAPIConnectionReuse(t *testing.T) {
130138

131139
req := &access.PingRequest{}
132140
expected := &access.PingResponse{}
133-
cn.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
141+
cn.handler.
142+
On("Ping",
143+
testifymock.Anything,
144+
testifymock.AnythingOfType("*access.PingRequest")).
145+
Return(expected, nil)
134146

135147
// create the factory
136148
connectionFactory := new(ConnectionFactoryImpl)
@@ -188,7 +200,11 @@ func TestProxyExecutionAPIConnectionReuse(t *testing.T) {
188200

189201
req := &execution.PingRequest{}
190202
expected := &execution.PingResponse{}
191-
en.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
203+
en.handler.
204+
On("Ping",
205+
testifymock.Anything,
206+
testifymock.AnythingOfType("*access.PingRequest")).
207+
Return(expected, nil)
192208

193209
// create the factory
194210
connectionFactory := new(ConnectionFactoryImpl)
@@ -250,7 +266,12 @@ func TestExecutionNodeClientTimeout(t *testing.T) {
250266
// setup the handler mock to not respond within the timeout
251267
req := &execution.PingRequest{}
252268
resp := &execution.PingResponse{}
253-
en.handler.On("Ping", testifymock.Anything, req).After(timeout+time.Second).Return(resp, nil)
269+
en.handler.
270+
On("Ping",
271+
testifymock.Anything,
272+
testifymock.AnythingOfType("*access.PingRequest")).
273+
After(timeout+time.Second).
274+
Return(resp, nil)
254275

255276
// create the factory
256277
connectionFactory := new(ConnectionFactoryImpl)
@@ -302,7 +323,12 @@ func TestCollectionNodeClientTimeout(t *testing.T) {
302323
// setup the handler mock to not respond within the timeout
303324
req := &access.PingRequest{}
304325
resp := &access.PingResponse{}
305-
cn.handler.On("Ping", testifymock.Anything, req).After(timeout+time.Second).Return(resp, nil)
326+
cn.handler.
327+
On("Ping",
328+
testifymock.Anything,
329+
testifymock.AnythingOfType("*access.PingRequest")).
330+
After(timeout+time.Second).
331+
Return(resp, nil)
306332

307333
// create the factory
308334
connectionFactory := new(ConnectionFactoryImpl)
@@ -353,11 +379,22 @@ func TestConnectionPoolFull(t *testing.T) {
353379
defer cn2.stop(t)
354380
defer cn3.stop(t)
355381

356-
req := &access.PingRequest{}
357382
expected := &access.PingResponse{}
358-
cn1.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
359-
cn2.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
360-
cn3.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
383+
cn1.handler.
384+
On("Ping",
385+
testifymock.Anything,
386+
testifymock.AnythingOfType("*access.PingRequest")).
387+
Return(expected, nil)
388+
cn2.handler.
389+
On("Ping",
390+
testifymock.Anything,
391+
testifymock.AnythingOfType("*access.PingRequest")).
392+
Return(expected, nil)
393+
cn3.handler.
394+
On("Ping",
395+
testifymock.Anything,
396+
testifymock.AnythingOfType("*access.PingRequest")).
397+
Return(expected, nil)
361398

362399
// create the factory
363400
connectionFactory := new(ConnectionFactoryImpl)
@@ -436,7 +473,11 @@ func TestConnectionPoolStale(t *testing.T) {
436473

437474
req := &access.PingRequest{}
438475
expected := &access.PingResponse{}
439-
cn.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
476+
cn.handler.
477+
On("Ping",
478+
testifymock.Anything,
479+
testifymock.AnythingOfType("*access.PingRequest")).
480+
Return(expected, nil)
440481

441482
// create the factory
442483
connectionFactory := new(ConnectionFactoryImpl)

0 commit comments

Comments
 (0)