From 73164883dbbf5c92eeeee235cf3a2a5520f3e66a Mon Sep 17 00:00:00 2001 From: Callum Morris Date: Mon, 10 Mar 2025 11:44:35 +1300 Subject: [PATCH] feat: add method to return underlying sqs client Useful when a wrapper function is not available for a particular use-case --- aws/sqs/sqs.go | 5 +++++ aws/sqs/sqs_integration_test.go | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/aws/sqs/sqs.go b/aws/sqs/sqs.go index 58c7a4b..9b36026 100644 --- a/aws/sqs/sqs.go +++ b/aws/sqs/sqs.go @@ -92,6 +92,11 @@ func (s *SQS) Ready() bool { return s.client != nil } +// Client returns the underlying SQS client. +func (s *SQS) Client() *sqs.Client { + return s.client +} + // Receive receives a raw message or error from the queue. // After a successful receive the message will be in flight // until it is either deleted or the visibility timeout expires diff --git a/aws/sqs/sqs_integration_test.go b/aws/sqs/sqs_integration_test.go index 0f26841..9f2a0f7 100644 --- a/aws/sqs/sqs_integration_test.go +++ b/aws/sqs/sqs_integration_test.go @@ -206,6 +206,24 @@ func TestCheckQueue(t *testing.T) { } +func TestSQSClient(t *testing.T) { + // ARRANGE + setup() + defer teardown() + + client, err := New() + ready := client.Ready() + + require.Nil(t, err) + require.True(t, ready) + + // ACTION + underlyingClient := client.Client() + + // ASSERT + assert.NotNil(t, underlyingClient) +} + func TestSQSNewAndReady(t *testing.T) { // ARRANGE setup()