Skip to content

Commit

Permalink
aws_dynamodb_table: add basic test for payPerRequest billing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonaj committed Oct 16, 2024
1 parent ebc8c0f commit 25244b6
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions internal/service/dynamodb/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,45 @@ func TestAccDynamoDBTable_BillingModeGSI_provisionedToPayPerRequest(t *testing.T
})
}

func TestAccDynamoDBTable_BillingMode_payPerRequestBasic(t *testing.T) {
ctx := acctest.Context(t)
var conf awstypes.TableDescription
resourceName := "aws_dynamodb_table.test"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.DynamoDBServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckTableDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccTableConfig_billingPayPerRequest(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckInitialTableExists(ctx, resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "billing_mode", string(awstypes.BillingModePayPerRequest)),
resource.TestCheckResourceAttr(resourceName, "read_capacity", acctest.Ct0),
resource.TestCheckResourceAttr(resourceName, "write_capacity", acctest.Ct0),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccTableConfig_billingPayPerRequestGSI(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckInitialTableExists(ctx, resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "billing_mode", string(awstypes.BillingModePayPerRequest)),
resource.TestCheckResourceAttr(resourceName, "read_capacity", acctest.Ct0),
resource.TestCheckResourceAttr(resourceName, "write_capacity", acctest.Ct0),
),
},
},
})
}

func TestAccDynamoDBTable_onDemandThroughput(t *testing.T) {
ctx := acctest.Context(t)
var conf awstypes.TableDescription
Expand Down Expand Up @@ -1781,8 +1820,8 @@ func TestAccDynamoDBTable_restoreCrossRegion(t *testing.T) {
testAccCheckInitialTableExists(ctx, resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rName),
resource.TestCheckResourceAttr(resourceNameRestore, names.AttrName, rNameRestore),
acctest.MatchResourceAttrRegionalARNRegion(resourceName, names.AttrARN, "dynamodb", acctest.Region(), regexache.MustCompile(`table/XXX`)),
acctest.MatchResourceAttrRegionalARNRegion(resourceNameRestore, names.AttrARN, "dynamodb", acctest.AlternateRegion(), regexache.MustCompile(`table/YYY`)),
acctest.MatchResourceAttrRegionalARNRegion(resourceName, names.AttrARN, "dynamodb", acctest.Region(), regexache.MustCompile(`table/.+$`)),
acctest.MatchResourceAttrRegionalARNRegion(resourceNameRestore, names.AttrARN, "dynamodb", acctest.AlternateRegion(), regexache.MustCompile(`table/.+$`)),
),
},
{
Expand Down

0 comments on commit 25244b6

Please sign in to comment.