Skip to content

Commit

Permalink
chore(spanner): add mocks for create session with multiplexed session…
Browse files Browse the repository at this point in the history
… unit tests
  • Loading branch information
harshachinta committed Dec 23, 2024
1 parent a1e72c4 commit 64a93e5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,21 @@ public void usesPreparedTransaction() {
com.google.protobuf.Timestamp.newBuilder()
.setSeconds(System.currentTimeMillis() * 1000))
.build()));
when(rpc.createSession(
Mockito.anyString(),
Mockito.anyString(),
Mockito.anyMap(),
Mockito.eq(null),
Mockito.eq(true)))
.thenAnswer(
invocation ->
Session.newBuilder()
.setName(invocation.getArguments()[0] + "/sessions/1")
.setMultiplexed(true)
.setCreateTime(
com.google.protobuf.Timestamp.newBuilder()
.setSeconds(System.currentTimeMillis() * 1000))
.build());
when(rpc.beginTransactionAsync(
Mockito.any(BeginTransactionRequest.class), Mockito.anyMap(), eq(true)))
.thenAnswer(
Expand Down Expand Up @@ -300,6 +315,21 @@ public void inlineBegin() {
com.google.protobuf.Timestamp.newBuilder()
.setSeconds(System.currentTimeMillis() * 1000))
.build()));
when(rpc.createSession(
Mockito.anyString(),
Mockito.anyString(),
Mockito.anyMap(),
Mockito.eq(null),
Mockito.eq(true)))
.thenAnswer(
invocation ->
Session.newBuilder()
.setName(invocation.getArguments()[0] + "/sessions/1")
.setMultiplexed(true)
.setCreateTime(
com.google.protobuf.Timestamp.newBuilder()
.setSeconds(System.currentTimeMillis() * 1000))
.build());
when(rpc.beginTransactionAsync(
Mockito.any(BeginTransactionRequest.class), Mockito.anyMap(), eq(true)))
.thenAnswer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@ public void usesPreparedTransaction() {
.setCreateTime(
Timestamp.newBuilder().setSeconds(System.currentTimeMillis() * 1000))
.build()));
when(rpc.createSession(
Mockito.anyString(),
Mockito.anyString(),
Mockito.anyMap(),
Mockito.eq(null),
Mockito.eq(true)))
.thenAnswer(
invocation ->
Session.newBuilder()
.setName(invocation.getArguments()[0] + "/sessions/1")
.setMultiplexed(true)
.setCreateTime(
com.google.protobuf.Timestamp.newBuilder()
.setSeconds(System.currentTimeMillis() * 1000))
.build());
when(rpc.beginTransactionAsync(
Mockito.any(BeginTransactionRequest.class), Mockito.anyMap(), eq(true)))
.thenAnswer(
Expand Down

0 comments on commit 64a93e5

Please sign in to comment.