Skip to content

Commit

Permalink
fix(pubsub): enable updating enable_exactly_once_delivery in fake pub…
Browse files Browse the repository at this point in the history
…sub (#5940)

Co-authored-by: Alex Hong <[email protected]>
  • Loading branch information
sachinpad and hongalex authored Apr 25, 2022
1 parent 80edea4 commit ee44bf6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pubsub/pstest/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,9 @@ func (s *GServer) UpdateSubscription(_ context.Context, req *pb.UpdateSubscripti
case "filter":
sub.proto.Filter = req.Subscription.Filter

case "enable_exactly_once_delivery":
sub.proto.EnableExactlyOnceDelivery = req.Subscription.EnableExactlyOnceDelivery

default:
return nil, status.Errorf(codes.InvalidArgument, "unknown field name %q", path)
}
Expand Down
29 changes: 29 additions & 0 deletions pubsub/pstest/fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,35 @@ func TestUpdateFilter(t *testing.T) {
}
}

func TestUpdateEnableExactlyOnceDelivery(t *testing.T) {
ctx := context.Background()
pclient, sclient, _, cleanup := newFake(ctx, t)
defer cleanup()

top := mustCreateTopic(ctx, t, pclient, &pb.Topic{Name: "projects/P/topics/T"})
sub := mustCreateSubscription(ctx, t, sclient, &pb.Subscription{
AckDeadlineSeconds: minAckDeadlineSecs,
Name: "projects/P/subscriptions/S",
Topic: top.Name,
})

update := &pb.Subscription{
AckDeadlineSeconds: sub.AckDeadlineSeconds,
Name: sub.Name,
Topic: top.Name,
EnableExactlyOnceDelivery: true,
}

updated := mustUpdateSubscription(ctx, t, sclient, &pb.UpdateSubscriptionRequest{
Subscription: update,
UpdateMask: &field_mask.FieldMask{Paths: []string{"enable_exactly_once_delivery"}},
})

if got, want := updated.EnableExactlyOnceDelivery, update.EnableExactlyOnceDelivery; got != want {
t.Fatalf("got %v, want %v", got, want)
}
}

// Test Create, Get, List, and Delete methods for schema client.
// Updating a schema is not available at this moment.
func TestSchemaAdminClient(t *testing.T) {
Expand Down

0 comments on commit ee44bf6

Please sign in to comment.