Skip to content

Commit 57914ec

Browse files
authored
fix(pubsub/pstest): align fake handling of bqconfig subscription to server behavior (#8066)
1 parent d73ed60 commit 57914ec

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

pubsub/pstest/fake.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,10 @@ func (s *GServer) CreateSubscription(_ context.Context, ps *pb.Subscription) (*p
499499
if ps.PushConfig == nil {
500500
ps.PushConfig = &pb.PushConfig{}
501501
}
502-
if ps.BigqueryConfig == nil {
503-
ps.BigqueryConfig = &pb.BigQueryConfig{}
504-
} else if ps.BigqueryConfig.Table != "" {
502+
// Consider any table set to mean the config is active.
503+
// We don't convert nil config to empty like with PushConfig above
504+
// as this mimics the live service behavior.
505+
if ps.GetBigqueryConfig() != nil && ps.GetBigqueryConfig().GetTable() != "" {
505506
ps.BigqueryConfig.State = pb.BigQueryConfig_ACTIVE
506507
}
507508
ps.TopicMessageRetentionDuration = top.proto.MessageRetentionDuration
@@ -605,7 +606,7 @@ func (s *GServer) UpdateSubscription(_ context.Context, req *pb.UpdateSubscripti
605606
sub.proto.PushConfig = req.Subscription.PushConfig
606607

607608
case "bigquery_config":
608-
// If bq config is nil here, it will have been cleared.
609+
// If bq config is nil here, it will be cleared.
609610
// Otherwise, we'll consider the subscription active if any table is set.
610611
sub.proto.BigqueryConfig = req.GetSubscription().GetBigqueryConfig()
611612
if sub.proto.GetBigqueryConfig() != nil {

pubsub/pstest/fake_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,8 +1583,8 @@ func TestSubscriptionPushPull(t *testing.T) {
15831583
if diff := testutil.Diff(got.PushConfig, new(pb.PushConfig)); diff != "" {
15841584
t.Errorf("sub.PushConfig should be zero value\n%s", diff)
15851585
}
1586-
if diff := testutil.Diff(got.BigqueryConfig, new(pb.BigQueryConfig)); diff != "" {
1587-
t.Errorf("sub.BigqueryConfig should be zero value\n%s", diff)
1586+
if got.BigqueryConfig != nil {
1587+
t.Errorf("sub.BigqueryConfig should be nil, got %s", got.BigqueryConfig)
15881588
}
15891589
}
15901590

0 commit comments

Comments
 (0)