Skip to content

Commit

Permalink
test(pubsublite): testing support for reservations (#4362)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdiep authored Jul 1, 2021
1 parent 2b3bb85 commit 7c07a3d
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions pubsublite/internal/test/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,18 @@ func (s *mockLiteServer) doOperationResponse(ctx context.Context, req interface{
return resp, nil
}

func (s *mockLiteServer) doReservationResponse(ctx context.Context, req interface{}) (*pb.Reservation, error) {
retResponse, retErr := s.popGlobalVerifiers(req)
if retErr != nil {
return nil, retErr
}
resp, ok := retResponse.(*pb.Reservation)
if !ok {
return nil, status.Errorf(codes.FailedPrecondition, "mockserver: invalid response type %T", retResponse)
}
return resp, nil
}

func (s *mockLiteServer) doEmptyResponse(ctx context.Context, req interface{}) (*emptypb.Empty, error) {
retResponse, retErr := s.popGlobalVerifiers(req)
if retErr != nil {
Expand Down Expand Up @@ -369,6 +381,22 @@ func (s *mockLiteServer) DeleteSubscription(ctx context.Context, req *pb.DeleteS
return s.doEmptyResponse(ctx, req)
}

func (s *mockLiteServer) CreateReservation(ctx context.Context, req *pb.CreateReservationRequest) (*pb.Reservation, error) {
return s.doReservationResponse(ctx, req)
}

func (s *mockLiteServer) GetReservation(ctx context.Context, req *pb.GetReservationRequest) (*pb.Reservation, error) {
return s.doReservationResponse(ctx, req)
}

func (s *mockLiteServer) UpdateReservation(ctx context.Context, req *pb.UpdateReservationRequest) (*pb.Reservation, error) {
return s.doReservationResponse(ctx, req)
}

func (s *mockLiteServer) DeleteReservation(ctx context.Context, req *pb.DeleteReservationRequest) (*emptypb.Empty, error) {
return s.doEmptyResponse(ctx, req)
}

func (s *mockLiteServer) ListTopics(ctx context.Context, req *pb.ListTopicsRequest) (*pb.ListTopicsResponse, error) {
retResponse, retErr := s.popGlobalVerifiers(req)
if retErr != nil {
Expand Down Expand Up @@ -405,6 +433,30 @@ func (s *mockLiteServer) ListSubscriptions(ctx context.Context, req *pb.ListSubs
return resp, nil
}

func (s *mockLiteServer) ListReservations(ctx context.Context, req *pb.ListReservationsRequest) (*pb.ListReservationsResponse, error) {
retResponse, retErr := s.popGlobalVerifiers(req)
if retErr != nil {
return nil, retErr
}
resp, ok := retResponse.(*pb.ListReservationsResponse)
if !ok {
return nil, status.Errorf(codes.FailedPrecondition, "mockserver: invalid response type %T", retResponse)
}
return resp, nil
}

func (s *mockLiteServer) ListReservationTopics(ctx context.Context, req *pb.ListReservationTopicsRequest) (*pb.ListReservationTopicsResponse, error) {
retResponse, retErr := s.popGlobalVerifiers(req)
if retErr != nil {
return nil, retErr
}
resp, ok := retResponse.(*pb.ListReservationTopicsResponse)
if !ok {
return nil, status.Errorf(codes.FailedPrecondition, "mockserver: invalid response type %T", retResponse)
}
return resp, nil
}

func (s *mockLiteServer) GetOperation(ctx context.Context, req *lrpb.GetOperationRequest) (*lrpb.Operation, error) {
return s.doOperationResponse(ctx, req)
}
Expand Down

0 comments on commit 7c07a3d

Please sign in to comment.