Files
query-orchestration/internal/serviceconfig/queue/config_test.go
T
Michael McGuinness b2cfeb3078 Merged in feature/lessmocks (pull request #151)
Less Mocks

* lessmocks
2025-05-23 10:10:48 +00:00

62 lines
1.4 KiB
Go

package queue_test
import (
"context"
"os"
"testing"
"queryorchestration/internal/serviceconfig/queue"
"queryorchestration/internal/test"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGetQueueClient(t *testing.T) {
c := queue.QueueConfig{}
assert.Nil(t, c.GetQueueClient())
c.QueueClient = &sqs.Client{}
assert.Equal(t, &sqs.Client{}, c.GetQueueClient())
}
func TestSetQueueClient(t *testing.T) {
os.Clearenv()
ctx := context.Background()
c := queue.QueueConfig{}
err := c.SetQueueClient(ctx)
require.NoError(t, err)
assert.NotNil(t, c.QueueClient)
}
func TestPingQueueByURL(t *testing.T) {
cfg := &AWSConfig{}
acfg := test.CreateAWSContainer(t, cfg)
test.SetQueueClient(t, t.Context(), cfg, acfg.ExternalEndpoint)
cfg.QueryURL = test.CreateQueue(t, cfg, test.QueryRunnerName)
err := cfg.PingQueueByURL(t.Context(), cfg.QueryURL)
require.NoError(t, err)
}
func TestGetSQSEndpoint(t *testing.T) {
cfg := queue.QueueConfig{}
name := cfg.GetSQSEndpoint()
assert.Equal(t, "", name)
cfg.AWSEndpointUrlSQS = "name"
name = cfg.GetSQSEndpoint()
assert.Equal(t, "name", name)
assert.Equal(t, cfg.AWSEndpointUrlSQS, name)
}
func TestSetSQSEndpoint(t *testing.T) {
cfg := queue.QueueConfig{}
assert.Equal(t, "", cfg.AWSEndpointUrlSQS)
url := "/i/am/here"
cfg.SetSQSEndpoint(url)
assert.Equal(t, url, cfg.AWSEndpointUrlSQS)
}