(t *testing.T)
| 29 | } |
| 30 | |
| 31 | func newClient(t *testing.T) Client { |
| 32 | t.Parallel() |
| 33 | |
| 34 | tableName := uuid.New().String() |
| 35 | indexName := "idx" |
| 36 | partitionKey := "pk" |
| 37 | sortKey := "sk" |
| 38 | sortKeyNum := "skN" |
| 39 | dynamoService := dynamodb.New(newConfig(t)) |
| 40 | _, err := dynamoService.CreateTableRequest(&dynamodb.CreateTableInput{ |
| 41 | AttributeDefinitions: []dynamodb.AttributeDefinition{ |
| 42 | {AttributeName: aws.String(partitionKey), AttributeType: "S"}, |
| 43 | {AttributeName: aws.String(sortKey), AttributeType: "S"}, |
| 44 | {AttributeName: aws.String(sortKeyNum), AttributeType: "N"}, |
| 45 | }, |
| 46 | BillingMode: "", |
| 47 | GlobalSecondaryIndexes: nil, |
| 48 | KeySchema: []dynamodb.KeySchemaElement{ |
| 49 | {AttributeName: aws.String(partitionKey), KeyType: dynamodb.KeyTypeHash}, |
| 50 | {AttributeName: aws.String(sortKey), KeyType: dynamodb.KeyTypeRange}, |
| 51 | }, |
| 52 | LocalSecondaryIndexes: []dynamodb.LocalSecondaryIndex{ |
| 53 | { |
| 54 | IndexName: aws.String(indexName), |
| 55 | KeySchema: []dynamodb.KeySchemaElement{ |
| 56 | {AttributeName: aws.String(partitionKey), KeyType: dynamodb.KeyTypeHash}, |
| 57 | {AttributeName: aws.String(sortKeyNum), KeyType: dynamodb.KeyTypeRange}, |
| 58 | }, |
| 59 | Projection: &dynamodb.Projection{ |
| 60 | NonKeyAttributes: nil, |
| 61 | ProjectionType: dynamodb.ProjectionTypeKeysOnly, |
| 62 | }, |
| 63 | }, |
| 64 | }, |
| 65 | ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ |
| 66 | ReadCapacityUnits: aws.Int64(1), |
| 67 | WriteCapacityUnits: aws.Int64(1), |
| 68 | }, |
| 69 | SSESpecification: nil, |
| 70 | StreamSpecification: nil, |
| 71 | TableName: aws.String(tableName), |
| 72 | Tags: nil, |
| 73 | }).Send(context.TODO()) |
| 74 | assert.NoError(t, err) |
| 75 | |
| 76 | return NewClient(dynamoService).Table(tableName, indexName).Attributes(partitionKey, sortKey, sortKeyNum) |
| 77 | } |
| 78 | |
| 79 | func newConfig(t *testing.T) aws.Config { |
| 80 | cfgs := external.Configs{} |
no test coverage detected