Made test DynamoDB endpoint configurable
All checks were successful
ci / build (push) Successful in 5m11s

This commit is contained in:
Leon Mika 2025-05-17 11:18:40 +10:00
parent aae3c419db
commit 40136e3936
3 changed files with 9 additions and 1 deletions

View file

@ -34,4 +34,5 @@ jobs:
go get ./...
go test -p 1 ./...
env:
TEST_DYNAMO_URL: "http://localstack:4566"
GOPRIVATE: "github:com/lmika/*"

View file

@ -31,6 +31,7 @@ jobs:
go test -p 1 ./...
env:
GOPRIVATE: "github:com/lmika/*"
TEST_DYNAMO_URL: "http://localstack:4566"
release-macos:
needs: build

View file

@ -2,6 +2,7 @@ package testdynamo
import (
"context"
"os"
"testing"
"github.com/aws/aws-sdk-go-v2/aws"
@ -28,8 +29,13 @@ func SetupTestTable(t *testing.T, testData []TestData) *dynamodb.Client {
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("abc", "123", "")))
assert.NoError(t, err)
testDynamoURL, ok := os.LookupEnv("TEST_DYNAMO_URL")
if !ok {
testDynamoURL = "http://localhost:4566"
}
dynamoClient := dynamodb.NewFromConfig(cfg,
dynamodb.WithEndpointResolver(dynamodb.EndpointResolverFromURL("http://localhost:4566")))
dynamodb.WithEndpointResolver(dynamodb.EndpointResolverFromURL(testDynamoURL)))
for _, table := range testData {
tableInput := &dynamodb.CreateTableInput{