Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Example: SNS

Demonstrates using testcontainers-floci-go to test SNS→SQS fan-out against a local Floci instance.

The test:

  1. Starts a Floci container
  2. Creates an SNS topic
  3. Creates an SQS queue and subscribes it to the topic
  4. Publishes a message to the topic
  5. Receives the message from SQS and verifies the SNS notification payload

Run

go test -v -timeout 300s ./examples/sns/...

Code walkthrough

// Start Floci
fc, err := floci.NewFlociContainer().Start(ctx)
t.Cleanup(func() { _ = fc.Stop(ctx) })

// Wire up SNS and SQS clients from the same config
cfg, err := config.LoadDefaultConfig(ctx,
    config.WithRegion(fc.GetRegion()),
    config.WithBaseEndpoint(fc.GetEndpoint()),
    config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
        fc.GetAccessKey(), fc.GetSecretKey(), "",
    )),
)
snsClient := sns.NewFromConfig(cfg)
sqsClient := sqs.NewFromConfig(cfg)