Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pubsub): enable updating enable_exactly_once_delivery in fake pubsub #5940

Merged
merged 2 commits into from
Apr 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pubsub/pstest/fake.go
Original file line number Diff line number Diff line change
@@ -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)
}
29 changes: 29 additions & 0 deletions pubsub/pstest/fake_test.go
Original file line number Diff line number Diff line change
@@ -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) {