Skip to content

Commit

Permalink
fix(pubsub): parse EnableMessageOrdering on GetSubscription (googleap…
Browse files Browse the repository at this point in the history
  • Loading branch information
hongalex authored and tritone committed Aug 25, 2020
1 parent 46e04b5 commit 9587aef
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pubsub/subscription.go
Expand Up @@ -308,16 +308,17 @@ func protoToSubscriptionConfig(pbSub *pb.Subscription, c *Client) (SubscriptionC
dlp := protoToDLP(pbSub.DeadLetterPolicy)
rp := protoToRetryPolicy(pbSub.RetryPolicy)
subC := SubscriptionConfig{
Topic: newTopic(c, pbSub.Topic),
AckDeadline: time.Second * time.Duration(pbSub.AckDeadlineSeconds),
RetainAckedMessages: pbSub.RetainAckedMessages,
RetentionDuration: rd,
Labels: pbSub.Labels,
ExpirationPolicy: expirationPolicy,
DeadLetterPolicy: dlp,
Filter: pbSub.Filter,
RetryPolicy: rp,
Detached: pbSub.Detached,
Topic: newTopic(c, pbSub.Topic),
AckDeadline: time.Second * time.Duration(pbSub.AckDeadlineSeconds),
RetainAckedMessages: pbSub.RetainAckedMessages,
RetentionDuration: rd,
Labels: pbSub.Labels,
ExpirationPolicy: expirationPolicy,
EnableMessageOrdering: pbSub.EnableMessageOrdering,
DeadLetterPolicy: dlp,
Filter: pbSub.Filter,
RetryPolicy: rp,
Detached: pbSub.Detached,
}
pc := protoToPushConfig(pbSub.PushConfig)
if pc != nil {
Expand Down
24 changes: 24 additions & 0 deletions pubsub/subscription_test.go
Expand Up @@ -375,3 +375,27 @@ func TestRetryPolicy_toProto(t *testing.T) {
t.Errorf("Roundtrip to Proto failed\ngot: - want: +\n%s", diff)
}
}

func TestOrdering_CreateSubscription(t *testing.T) {
ctx := context.Background()
client, srv := newFake(t)
defer client.Close()
defer srv.Close()

topic := mustCreateTopic(t, client, "t")
subConfig := SubscriptionConfig{
Topic: topic,
EnableMessageOrdering: true,
}
orderSub, err := client.CreateSubscription(ctx, "s", subConfig)
if err != nil {
t.Fatal(err)
}
cfg, err := orderSub.Config(ctx)
if err != nil {
t.Fatal(err)
}
if !cfg.EnableMessageOrdering {
t.Fatalf("Expected EnableMessageOrdering to be true in %s", orderSub.String())
}
}

0 comments on commit 9587aef

Please sign in to comment.