From cae3c4d04abf5b43f4c6dc3595f8ee386bb854f3 Mon Sep 17 00:00:00 2001 From: Karen Chen Date: Wed, 11 Sep 2024 12:36:13 -0400 Subject: [PATCH] Expose az sender Close() (#254) * expose az sender close() * fix UT --- v2/sender.go | 1 + v2/sender_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/v2/sender.go b/v2/sender.go index 6b8b8ae..5f20ff8 100644 --- a/v2/sender.go +++ b/v2/sender.go @@ -25,6 +25,7 @@ type AzServiceBusSender interface { SendMessage(ctx context.Context, message *azservicebus.Message, options *azservicebus.SendMessageOptions) error SendMessageBatch(ctx context.Context, batch *azservicebus.MessageBatch, options *azservicebus.SendMessageBatchOptions) error NewMessageBatch(ctx context.Context, options *azservicebus.MessageBatchOptions) (*azservicebus.MessageBatch, error) + Close(ctx context.Context) error } // Sender contains an SBSender used to send the message to the ServiceBus queue and a Marshaller used to marshal any struct into a ServiceBus message diff --git a/v2/sender_test.go b/v2/sender_test.go index d3eac6d..91bff3b 100644 --- a/v2/sender_test.go +++ b/v2/sender_test.go @@ -330,6 +330,7 @@ type fakeAzSender struct { NewMessageBatchReturnValue *azservicebus.MessageBatch NewMessageBatchErr error SendMessageBatchReceivedValue *azservicebus.MessageBatch + CloseErr error } func (f *fakeAzSender) SendMessage( @@ -370,3 +371,7 @@ func (f *fakeAzSender) NewMessageBatch( options *azservicebus.MessageBatchOptions) (*azservicebus.MessageBatch, error) { return f.NewMessageBatchReturnValue, f.NewMessageBatchErr } + +func (f *fakeAzSender) Close(ctx context.Context) error { + return f.CloseErr +}