Documentation
¶
Overview ¶
Package local provides testing functionality using DynamoDB local as Docker image.
The DynamoDB local image is started via Testcontainers DynamoDB module. Docker daemon must have been started prior to executing the tests. On Linux, Docker can be installed via system's default package manager. On MacOS and Windows, use Docker Desktop if possible. If using Colima on MacOS, be sure to follow Using Colima with Docker to set DOCKER_HOST and/or TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE accordingly.
Index ¶
- func Connect(t *testing.T, optFns ...func(opts *Options)) *dynamodb.Client
- func Default(t *testing.T, optFns ...func(opts *Options)) *dynamodb.Client
- func DefaultSkippable(t *testing.T, optFns ...func(opts *Options)) *dynamodb.Client
- func GetItem(t *testing.T, client *dynamodb.Client, tableName string, hashKeyName string, ...) map[string]types.AttributeValue
- func WithClientOptions(optFns ...func(opts *dynamodb.Options)) func(opts *Options)
- func WithContainerOptions(optFns ...testcontainers.ContainerCustomizer) func(opts *Options)
- func WithLoadOptions(optFns ...func(opts *config.LoadOptions) error) func(opts *Options)
- func WithStubCredentialsProvider() func(opts *Options)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
Default is a variation of Connect with sensible defaults.
The settings are enabled by Default:
- DynamoDB local is started with -inMemory -sharedDb -disableTelemetry per usage notes. This is fine since each test should be creating their own connection.
- WithStubCredentialsProvider is added.
func DefaultSkippable ¶
DefaultSkippable is a variation of Default that skips the test if DOCKER_HOST is not given.
func GetItem ¶
func GetItem(t *testing.T, client *dynamodb.Client, tableName string, hashKeyName string, hashKeyValue any, a ...any) map[string]types.AttributeValue
GetItem makes a GetItem request and fails the test if the call fails.
The hash key name and value pair must be given. The sort key name and value pair is optional; if given, len(a) must be exactly 2.
func WithClientOptions ¶
WithClientOptions adds client options passed to every DynamoDB calls by the client returned by Connect.
func WithContainerOptions ¶
func WithContainerOptions(optFns ...testcontainers.ContainerCustomizer) func(opts *Options)
WithContainerOptions adds customisations to the test container such as testcontainersdynamodb.WithSharedDB.
func WithLoadOptions ¶
func WithLoadOptions(optFns ...func(opts *config.LoadOptions) error) func(opts *Options)
WithLoadOptions adds customisations to the config.LoadDefaultConfig.
func WithStubCredentialsProvider ¶
func WithStubCredentialsProvider() func(opts *Options)
WithStubCredentialsProvider modifies the credentials to use stub values since DynamoDB local doesn't care.