Documentation
¶
Overview ¶
Package fakedb provides a deterministic, state-backed DynamoDBAPI fake for consumer tests.
The fake is a local testing aid. It is intentionally bounded to TableTheory's scenario-validated behavior and should not be treated as a DynamoDB emulator. Unlike the scripted doubles in pkg/mocks, it stores item state and evaluates supported condition expressions, including the partition-key not-exists guard used by Create.
Index ¶
- type Fake
- func (f *Fake) BatchGetItem(_ context.Context, params *dynamodb.BatchGetItemInput, ...) (*dynamodb.BatchGetItemOutput, error)
- func (f *Fake) BatchWriteItem(_ context.Context, params *dynamodb.BatchWriteItemInput, ...) (*dynamodb.BatchWriteItemOutput, error)
- func (f *Fake) CreateBackup(_ context.Context, params *dynamodb.CreateBackupInput, ...) (*dynamodb.CreateBackupOutput, error)
- func (f *Fake) CreateTable(_ context.Context, params *dynamodb.CreateTableInput, ...) (*dynamodb.CreateTableOutput, error)
- func (f *Fake) DeleteItem(_ context.Context, params *dynamodb.DeleteItemInput, ...) (*dynamodb.DeleteItemOutput, error)
- func (f *Fake) DeleteTable(_ context.Context, params *dynamodb.DeleteTableInput, ...) (*dynamodb.DeleteTableOutput, error)
- func (f *Fake) DescribeTable(_ context.Context, params *dynamodb.DescribeTableInput, ...) (*dynamodb.DescribeTableOutput, error)
- func (f *Fake) DescribeTimeToLive(_ context.Context, params *dynamodb.DescribeTimeToLiveInput, ...) (*dynamodb.DescribeTimeToLiveOutput, error)
- func (f *Fake) GetItem(_ context.Context, params *dynamodb.GetItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
- func (f *Fake) Items(tableName string) []map[string]types.AttributeValue
- func (f *Fake) ListTables(_ context.Context, params *dynamodb.ListTablesInput, ...) (*dynamodb.ListTablesOutput, error)
- func (f *Fake) PutItem(_ context.Context, params *dynamodb.PutItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
- func (f *Fake) Query(_ context.Context, params *dynamodb.QueryInput, _ ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
- func (f *Fake) QueueTransactionCancellation(reasons []types.CancellationReason)
- func (f *Fake) QueueTransactionError(err error)
- func (f *Fake) Reset()
- func (f *Fake) Scan(_ context.Context, params *dynamodb.ScanInput, _ ...func(*dynamodb.Options)) (*dynamodb.ScanOutput, error)
- func (f *Fake) Seed(tableName string, items ...map[string]types.AttributeValue) error
- func (f *Fake) TransactGetItems(_ context.Context, params *dynamodb.TransactGetItemsInput, ...) (*dynamodb.TransactGetItemsOutput, error)
- func (f *Fake) TransactWriteItems(_ context.Context, params *dynamodb.TransactWriteItemsInput, ...) (*dynamodb.TransactWriteItemsOutput, error)
- func (f *Fake) UpdateItem(_ context.Context, params *dynamodb.UpdateItemInput, ...) (*dynamodb.UpdateItemOutput, error)
- func (f *Fake) UpdateTable(_ context.Context, params *dynamodb.UpdateTableInput, ...) (*dynamodb.UpdateTableOutput, error)
- func (f *Fake) UpdateTimeToLive(_ context.Context, params *dynamodb.UpdateTimeToLiveInput, ...) (*dynamodb.UpdateTimeToLiveOutput, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake is an in-memory implementation of the TableTheory DynamoDBAPI seam.
func New ¶
func New() *Fake
New returns an empty in-memory DynamoDB fake. Use it for tests whose outcome depends on stored state or supported condition expressions; pkg/mocks does not evaluate those conditions. It keeps the fake's historical permissive TTL behavior; use NewWithOptions with WithDynamoDBTTLValidation to make UpdateTimeToLive reject what DynamoDB rejects.
func NewWithOptions ¶ added in v6.2.0
NewWithOptions returns an empty in-memory DynamoDB fake configured with the supplied options.
func (*Fake) BatchGetItem ¶
func (f *Fake) BatchGetItem(_ context.Context, params *dynamodb.BatchGetItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.BatchGetItemOutput, error)
func (*Fake) BatchWriteItem ¶
func (f *Fake) BatchWriteItem(_ context.Context, params *dynamodb.BatchWriteItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.BatchWriteItemOutput, error)
func (*Fake) CreateBackup ¶
func (f *Fake) CreateBackup(_ context.Context, params *dynamodb.CreateBackupInput, _ ...func(*dynamodb.Options)) (*dynamodb.CreateBackupOutput, error)
func (*Fake) CreateTable ¶
func (f *Fake) CreateTable(_ context.Context, params *dynamodb.CreateTableInput, _ ...func(*dynamodb.Options)) (*dynamodb.CreateTableOutput, error)
func (*Fake) DeleteItem ¶
func (f *Fake) DeleteItem(_ context.Context, params *dynamodb.DeleteItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error)
func (*Fake) DeleteTable ¶
func (f *Fake) DeleteTable(_ context.Context, params *dynamodb.DeleteTableInput, _ ...func(*dynamodb.Options)) (*dynamodb.DeleteTableOutput, error)
func (*Fake) DescribeTable ¶
func (f *Fake) DescribeTable(_ context.Context, params *dynamodb.DescribeTableInput, _ ...func(*dynamodb.Options)) (*dynamodb.DescribeTableOutput, error)
func (*Fake) DescribeTimeToLive ¶ added in v6.2.0
func (f *Fake) DescribeTimeToLive(_ context.Context, params *dynamodb.DescribeTimeToLiveInput, _ ...func(*dynamodb.Options)) (*dynamodb.DescribeTimeToLiveOutput, error)
DescribeTimeToLive reports the TTL state the fake records from UpdateTimeToLive, matching the DynamoDB status and attribute shape.
func (*Fake) GetItem ¶
func (f *Fake) GetItem(_ context.Context, params *dynamodb.GetItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
func (*Fake) Items ¶
func (f *Fake) Items(tableName string) []map[string]types.AttributeValue
Items returns a deterministic snapshot of the table's stored items.
func (*Fake) ListTables ¶
func (f *Fake) ListTables(_ context.Context, params *dynamodb.ListTablesInput, _ ...func(*dynamodb.Options)) (*dynamodb.ListTablesOutput, error)
func (*Fake) PutItem ¶
func (f *Fake) PutItem(_ context.Context, params *dynamodb.PutItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
func (*Fake) Query ¶
func (f *Fake) Query(_ context.Context, params *dynamodb.QueryInput, _ ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
func (*Fake) QueueTransactionCancellation ¶
func (f *Fake) QueueTransactionCancellation(reasons []types.CancellationReason)
QueueTransactionCancellation makes every TransactWriteItems call fail with a synthesized TransactionCanceledException carrying the supplied reasons in position, until it is cleared. A nil slice clears any queued cancellation; an empty (non-nil) slice queues a cancellation with no reasons. It is a test seam for exercising the cancellation taxonomy without real DynamoDB.
func (*Fake) QueueTransactionError ¶
QueueTransactionError makes every TransactWriteItems call fail with err, returned unchanged, until it is cleared. A nil err clears any queued failure. It is a test seam for exercising non-cancellation (transport) failures against the same path.
func (*Fake) Reset ¶
func (f *Fake) Reset()
Reset removes all fake tables and items and clears any queued transaction failure.
func (*Fake) TransactGetItems ¶
func (f *Fake) TransactGetItems(_ context.Context, params *dynamodb.TransactGetItemsInput, _ ...func(*dynamodb.Options)) (*dynamodb.TransactGetItemsOutput, error)
func (*Fake) TransactWriteItems ¶
func (f *Fake) TransactWriteItems(_ context.Context, params *dynamodb.TransactWriteItemsInput, _ ...func(*dynamodb.Options)) (*dynamodb.TransactWriteItemsOutput, error)
func (*Fake) UpdateItem ¶
func (f *Fake) UpdateItem(_ context.Context, params *dynamodb.UpdateItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.UpdateItemOutput, error)
func (*Fake) UpdateTable ¶
func (f *Fake) UpdateTable(_ context.Context, params *dynamodb.UpdateTableInput, _ ...func(*dynamodb.Options)) (*dynamodb.UpdateTableOutput, error)
func (*Fake) UpdateTimeToLive ¶
func (f *Fake) UpdateTimeToLive(_ context.Context, params *dynamodb.UpdateTimeToLiveInput, _ ...func(*dynamodb.Options)) (*dynamodb.UpdateTimeToLiveOutput, error)
type Option ¶ added in v6.2.0
type Option func(*Fake)
Option configures a Fake at construction time.
func WithDynamoDBTTLValidation ¶ added in v6.2.0
func WithDynamoDBTTLValidation() Option
WithDynamoDBTTLValidation makes UpdateTimeToLive reject the requests DynamoDB rejects: a missing TimeToLiveSpecification.AttributeName, enabling TTL on the attribute that is already enabled, and enabling TTL while another attribute is enabled. The default fake accepts all three, matching the behavior existing consumer tests rely on.