Skip to content

Commit

Permalink
core/session: fix flaky test (#4730)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdoxsey committed Nov 9, 2023
1 parent d21cdb3 commit 6de9f12
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/grpc/session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ func TestDelete(t *testing.T) {
func TestGet(t *testing.T) {
t.Parallel()

ctrl := gomock.NewController(t)
client := mock_databroker.NewMockDataBrokerServiceClient(ctrl)

ctx := context.Background()

t.Run("ok", func(t *testing.T) {
Expand All @@ -60,6 +57,8 @@ func TestGet(t *testing.T) {
Id: "session-id",
UserId: "user-id",
}
ctrl := gomock.NewController(t)
client := mock_databroker.NewMockDataBrokerServiceClient(ctrl)
client.EXPECT().Get(ctx, gomock.Any(), []grpc.CallOption{}).DoAndReturn(
func(_ context.Context, r *databroker.GetRequest, _ ...grpc.CallOption) (*databroker.GetResponse, error) {
assert.Equal(t, "type.googleapis.com/session.Session", r.Type)
Expand All @@ -77,6 +76,8 @@ func TestGet(t *testing.T) {
t.Parallel()

rpcErr := status.Error(codes.Unavailable, "dummy error for testing")
ctrl := gomock.NewController(t)
client := mock_databroker.NewMockDataBrokerServiceClient(ctrl)
client.EXPECT().Get(ctx, gomock.Any(), []grpc.CallOption{}).DoAndReturn(
func(_ context.Context, r *databroker.GetRequest, _ ...grpc.CallOption) (*databroker.GetResponse, error) {
assert.Equal(t, "type.googleapis.com/session.Session", r.Type)
Expand All @@ -91,6 +92,8 @@ func TestGet(t *testing.T) {
t.Run("unmarshal error", func(t *testing.T) {
t.Parallel()

ctrl := gomock.NewController(t)
client := mock_databroker.NewMockDataBrokerServiceClient(ctrl)
client.EXPECT().Get(ctx, gomock.Any(), []grpc.CallOption{}).DoAndReturn(
func(_ context.Context, r *databroker.GetRequest, _ ...grpc.CallOption) (*databroker.GetResponse, error) {
assert.Equal(t, "type.googleapis.com/session.Session", r.Type)
Expand Down

0 comments on commit 6de9f12

Please sign in to comment.