Skip to content

Commit

Permalink
fix(pubsub/pstest): align fake handling of bqconfig subscription to s…
Browse files Browse the repository at this point in the history
…erver behavior (#8066)
  • Loading branch information
hongalex authored Jun 8, 2023
1 parent d73ed60 commit 57914ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions pubsub/pstest/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,10 @@ func (s *GServer) CreateSubscription(_ context.Context, ps *pb.Subscription) (*p
if ps.PushConfig == nil {
ps.PushConfig = &pb.PushConfig{}
}
if ps.BigqueryConfig == nil {
ps.BigqueryConfig = &pb.BigQueryConfig{}
} else if ps.BigqueryConfig.Table != "" {
// Consider any table set to mean the config is active.
// We don't convert nil config to empty like with PushConfig above
// as this mimics the live service behavior.
if ps.GetBigqueryConfig() != nil && ps.GetBigqueryConfig().GetTable() != "" {
ps.BigqueryConfig.State = pb.BigQueryConfig_ACTIVE
}
ps.TopicMessageRetentionDuration = top.proto.MessageRetentionDuration
Expand Down Expand Up @@ -605,7 +606,7 @@ func (s *GServer) UpdateSubscription(_ context.Context, req *pb.UpdateSubscripti
sub.proto.PushConfig = req.Subscription.PushConfig

case "bigquery_config":
// If bq config is nil here, it will have been cleared.
// If bq config is nil here, it will be cleared.
// Otherwise, we'll consider the subscription active if any table is set.
sub.proto.BigqueryConfig = req.GetSubscription().GetBigqueryConfig()
if sub.proto.GetBigqueryConfig() != nil {
Expand Down
4 changes: 2 additions & 2 deletions pubsub/pstest/fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1583,8 +1583,8 @@ func TestSubscriptionPushPull(t *testing.T) {
if diff := testutil.Diff(got.PushConfig, new(pb.PushConfig)); diff != "" {
t.Errorf("sub.PushConfig should be zero value\n%s", diff)
}
if diff := testutil.Diff(got.BigqueryConfig, new(pb.BigQueryConfig)); diff != "" {
t.Errorf("sub.BigqueryConfig should be zero value\n%s", diff)
if got.BigqueryConfig != nil {
t.Errorf("sub.BigqueryConfig should be nil, got %s", got.BigqueryConfig)
}
}

Expand Down

0 comments on commit 57914ec

Please sign in to comment.