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 get ./...
go test -p 1 ./... go test -p 1 ./...
env: env:
TEST_DYNAMO_URL: "http://localstack:4566"
GOPRIVATE: "github:com/lmika/*" GOPRIVATE: "github:com/lmika/*"

View file

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

View file

@ -2,6 +2,7 @@ package testdynamo
import ( import (
"context" "context"
"os"
"testing" "testing"
"github.com/aws/aws-sdk-go-v2/aws" "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", ""))) config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("abc", "123", "")))
assert.NoError(t, err) assert.NoError(t, err)
testDynamoURL, ok := os.LookupEnv("TEST_DYNAMO_URL")
if !ok {
testDynamoURL = "http://localhost:4566"
}
dynamoClient := dynamodb.NewFromConfig(cfg, dynamoClient := dynamodb.NewFromConfig(cfg,
dynamodb.WithEndpointResolver(dynamodb.EndpointResolverFromURL("http://localhost:4566"))) dynamodb.WithEndpointResolver(dynamodb.EndpointResolverFromURL(testDynamoURL)))
for _, table := range testData { for _, table := range testData {
tableInput := &dynamodb.CreateTableInput{ tableInput := &dynamodb.CreateTableInput{