basicintegrationsetup
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
"github.com/testcontainers/testcontainers-go/network"
|
||||
"github.com/testcontainers/testcontainers-go/wait"
|
||||
@@ -236,3 +238,43 @@ func sendMessage(t *testing.T, ctx context.Context, queue *sqs.Client, message m
|
||||
t.Fatalf("Failed to send message: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func assertMessageWait(t *testing.T, ctx context.Context, queue *queue, msgType string) {
|
||||
time.Sleep(time.Second)
|
||||
|
||||
result, err := queue.Client.ReceiveMessage(ctx, &sqs.ReceiveMessageInput{
|
||||
QueueUrl: &queue.Config.URL,
|
||||
MaxNumberOfMessages: 1,
|
||||
WaitTimeSeconds: 5,
|
||||
VisibilityTimeout: 2,
|
||||
MessageAttributeNames: []string{
|
||||
"type",
|
||||
},
|
||||
})
|
||||
|
||||
assert.Nil(t, err)
|
||||
for _, message := range result.Messages {
|
||||
assert.Equal(t, msgType, *message.MessageAttributes["type"].StringValue)
|
||||
}
|
||||
}
|
||||
|
||||
func createDependencies(t *testing.T, ctx context.Context) (*queue, func()) {
|
||||
network := createNetwork(t, ctx)
|
||||
|
||||
dbconfig, dbContainer := createDB(t, ctx, network)
|
||||
|
||||
queue := createQueue(t, ctx, network)
|
||||
|
||||
container := createContainer(t, ctx, containerConfig{
|
||||
Queue: *queue.Config,
|
||||
DB: dbconfig,
|
||||
Network: network,
|
||||
})
|
||||
|
||||
return queue, func() {
|
||||
testcontainers.CleanupNetwork(t, network)
|
||||
dbContainer.Terminate(ctx)
|
||||
(*queue.Container).Terminate(ctx)
|
||||
container.Terminate(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user