Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: pxp928 <parth.psu@gmail.com>
  • Loading branch information
pxp928 committed Mar 31, 2024
1 parent a0ed278 commit af19c89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pubsub/awssnssqs/awssnssqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,16 @@ func (o *URLOpener) OpenSubscriptionURL(ctx context.Context, u *url.URL) (*pubsu
}
q.Del("waittime")
}
// SQS supports receiving at most 10 messages at a time:
// https://godoc.org/github.com/aws/aws-sdk-go/service/sqs#SQS.ReceiveMessage
// if value is higher than 10, it will default to 10
if receiverMaxBatchStr := q.Get("receivermaxbatch"); receiverMaxBatchStr != "" {
var err error
opts.ReceiveBatcherOptions.MaxBatchSize, err = strconv.Atoi(receiverMaxBatchStr)
if err != nil {
return nil, fmt.Errorf("invalid value %q for receivermaxbatch: %v", receiverMaxBatchStr, err)
}
q.Del("recievermaxbatch")
q.Del("receivermaxbatch")
}
qURL := "https://" + path.Join(u.Host, u.Path)
if o.UseV2 {
Expand Down
4 changes: 4 additions & 0 deletions pubsub/awssnssqs/awssnssqs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,10 @@ func TestOpenSubscriptionFromURL(t *testing.T) {
{"awssqs://sqs.us-east-2.amazonaws.com/99999/my-queue?waittime=foo", true},
// Invalid parameter.
{"awssqs://sqs.us-east-2.amazonaws.com/99999/my-queue?param=value", true},
// OK, setting receivermaxbatch.
{"awssqs://sqs.us-east-2.amazonaws.com/99999/my-queue?receivermaxbatch=5", false},
// Invalid receivermaxbatch.
{"awssqs://sqs.us-east-2.amazonaws.com/99999/my-queue?receivermaxbatch=foo", true},
}

ctx := context.Background()
Expand Down

0 comments on commit af19c89

Please sign in to comment.