@@ -346,8 +346,8 @@ func TestSubscriptionDeadLetter(t *testing.T) {
346
346
347
347
}
348
348
for _ , m := range pull .ReceivedMessages {
349
- if int32 (i ) != m .DeliveryAttempt {
350
- t .Fatalf ("message delivery attempt not the expected one. expected: %d, actual: %d" , i , m .DeliveryAttempt )
349
+ if int32 (i + 1 ) != m .DeliveryAttempt {
350
+ t .Fatalf ("message delivery attempt not the expected one. expected: %d, actual: %d" , i + 1 , m .DeliveryAttempt )
351
351
}
352
352
_ , err := server .GServer .ModifyAckDeadline (ctx , & pb.ModifyAckDeadlineRequest {
353
353
Subscription : sub .Name ,
@@ -551,19 +551,33 @@ func TestStreamingPull(t *testing.T) {
551
551
pclient , sclient , srv , cleanup := newFake (context .TODO (), t )
552
552
defer cleanup ()
553
553
554
+ deadLetterTopic := mustCreateTopic (context .TODO (), t , pclient , & pb.Topic {
555
+ Name : "projects/P/topics/deadLetter" ,
556
+ })
557
+
554
558
top := mustCreateTopic (context .TODO (), t , pclient , & pb.Topic {Name : "projects/P/topics/T" })
555
559
sub := mustCreateSubscription (context .TODO (), t , sclient , & pb.Subscription {
556
560
Name : "projects/P/subscriptions/S" ,
557
561
Topic : top .Name ,
558
562
AckDeadlineSeconds : 10 ,
563
+ DeadLetterPolicy : & pb.DeadLetterPolicy {
564
+ DeadLetterTopic : deadLetterTopic .Name ,
565
+ MaxDeliveryAttempts : 3 ,
566
+ },
559
567
})
560
568
561
569
want := publish (t , srv , pclient , top , []* pb.PubsubMessage {
562
570
{Data : []byte ("d1" )},
563
571
{Data : []byte ("d2" )},
564
572
{Data : []byte ("d3" )},
565
573
})
566
- got := pubsubMessages (streamingPullN (context .TODO (), t , len (want ), sclient , sub ))
574
+ received := streamingPullN (context .TODO (), t , len (want ), sclient , sub )
575
+ for _ , m := range received {
576
+ if m .DeliveryAttempt != 1 {
577
+ t .Errorf ("got DeliveryAttempt==%d, want 1" , m .DeliveryAttempt )
578
+ }
579
+ }
580
+ got := pubsubMessages (received )
567
581
if diff := testutil .Diff (got , want ); diff != "" {
568
582
t .Error (diff )
569
583
}
0 commit comments