Skip to content

Commit

Permalink
chore: wrap errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Sep 27, 2024
1 parent 4fbae32 commit 93a9d01
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions modules/dynamodb/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dynamodb

import (
"context"
"errors"
"fmt"

"github.com/testcontainers/testcontainers-go"
Expand Down Expand Up @@ -55,18 +56,20 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom

// ConnectionString returns DynamoDB local endpoint host and port in <host>:<port> format
func (c *DynamoDBContainer) ConnectionString(ctx context.Context) (string, error) {
var errs []error

mappedPort, err := c.MappedPort(ctx, port)
if err != nil {
return "", err
errs = append(errs, fmt.Errorf("mapped port: %w", err))
}

hostIP, err := c.Host(ctx)
if err != nil {
return "", err
errs = append(errs, fmt.Errorf("host: %w", err))
}

uri := fmt.Sprintf("%s:%s", hostIP, mappedPort.Port())
return uri, nil
return uri, errors.Join(errs...)
}

// WithSharedDB allows container reuse between successive runs. Data will be persisted
Expand Down

0 comments on commit 93a9d01

Please sign in to comment.