Skip to content

Commit 1173735

Browse files
committed
internal/acctest: add provider_meta config, smoke tests
Plugin SDK V2 based resource: ```console % make t K=logs T=TestAccLogsLogGroup_providerMeta make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... make: Running acceptance tests on branch: 🌿 f-provider-meta-simple 🌿... TF_ACC=1 go1.24.11 test ./internal/service/logs/... -v -count 1 -parallel 20 -run='TestAccLogsLogGroup_providerMeta' -timeout 360m -vet=off 2025/12/08 13:31:36 Creating Terraform AWS Provider (SDKv2-style)... 2025/12/08 13:31:36 Initializing Terraform AWS Provider (SDKv2-style)... --- PASS: TestAccLogsLogGroup_providerMeta (14.83s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/logs 21.333s ``` Plugin Framework based resource: ```console % make t K=iot T=TestAccIoTBillingGroup_providerMeta make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... make: Running acceptance tests on branch: 🌿 f-provider-meta-simple 🌿... TF_ACC=1 go1.24.11 test ./internal/service/iot/... -v -count 1 -parallel 20 -run='TestAccIoTBillingGroup_providerMeta' -timeout 360m -vet=off 2025/12/08 13:26:38 Creating Terraform AWS Provider (SDKv2-style)... 2025/12/08 13:26:38 Initializing Terraform AWS Provider (SDKv2-style)... --- PASS: TestAccIoTBillingGroup_providerMeta (14.89s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/iot 21.397s ```
1 parent 5076ec8 commit 1173735

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

internal/acctest/configs.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,19 @@ provider "aws" {
318318
`, os.Getenv(envvar.AccAssumeRoleARN), policy)
319319
}
320320

321+
// ConfigProviderMeta returns a terraform block with provider_meta configured
322+
func ConfigProviderMeta() string {
323+
return `
324+
terraform {
325+
provider_meta "aws" {
326+
user_agent = [
327+
"test-module/0.0.1 (test comment)",
328+
]
329+
}
330+
}
331+
`
332+
}
333+
321334
const testAccProviderConfigBase = `
322335
data "aws_region" "provider_test" {}
323336

internal/service/iot/billing_group_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,37 @@ func TestAccIoTBillingGroup_requiredTags_disabled(t *testing.T) {
632632
})
633633
}
634634

635+
// A smoke test to verify setting provider_meta does not trigger unexpected
636+
// behavior for Plugin Framework based resources
637+
func TestAccIoTBillingGroup_providerMeta(t *testing.T) {
638+
ctx := acctest.Context(t)
639+
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
640+
resourceName := "aws_iot_billing_group.test"
641+
642+
resource.ParallelTest(t, resource.TestCase{
643+
PreCheck: func() { acctest.PreCheck(ctx, t) },
644+
ErrorCheck: acctest.ErrorCheck(t, names.IoTServiceID),
645+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
646+
CheckDestroy: testAccCheckBillingGroupDestroy(ctx),
647+
Steps: []resource.TestStep{
648+
{
649+
Config: acctest.ConfigCompose(
650+
acctest.ConfigProviderMeta(),
651+
testAccBillingGroupConfig_basic(rName),
652+
),
653+
Check: resource.ComposeAggregateTestCheckFunc(
654+
testAccCheckBillingGroupExists(ctx, resourceName),
655+
),
656+
},
657+
{
658+
ResourceName: resourceName,
659+
ImportState: true,
660+
ImportStateVerify: true,
661+
},
662+
},
663+
})
664+
}
665+
635666
func testAccCheckBillingGroupExists(ctx context.Context, n string) resource.TestCheckFunc {
636667
return func(s *terraform.State) error {
637668
rs, ok := s.RootModule().Resources[n]

internal/service/logs/group_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,38 @@ func TestAccLogsLogGroup_deletionProtectionEnabled(t *testing.T) {
800800
})
801801
}
802802

803+
// A smoke test to verify setting provider_meta does not trigger unexpected
804+
// behavior for Plugin SDK V2 based resources
805+
func TestAccLogsLogGroup_providerMeta(t *testing.T) {
806+
ctx := acctest.Context(t)
807+
var v types.LogGroup
808+
rName := acctest.RandomWithPrefix(t, acctest.ResourcePrefix)
809+
resourceName := "aws_cloudwatch_log_group.test"
810+
811+
acctest.ParallelTest(ctx, t, resource.TestCase{
812+
PreCheck: func() { acctest.PreCheck(ctx, t) },
813+
ErrorCheck: acctest.ErrorCheck(t, names.LogsServiceID),
814+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
815+
CheckDestroy: testAccCheckLogGroupDestroy(ctx, t),
816+
Steps: []resource.TestStep{
817+
{
818+
Config: acctest.ConfigCompose(
819+
acctest.ConfigProviderMeta(),
820+
testAccGroupConfig_basic(rName),
821+
),
822+
Check: resource.ComposeAggregateTestCheckFunc(
823+
testAccCheckLogGroupExists(ctx, t, resourceName, &v),
824+
),
825+
},
826+
{
827+
ResourceName: resourceName,
828+
ImportState: true,
829+
ImportStateVerify: true,
830+
},
831+
},
832+
})
833+
}
834+
803835
func testAccCheckLogGroupExists(ctx context.Context, t *testing.T, n string, v *types.LogGroup) resource.TestCheckFunc {
804836
return func(s *terraform.State) error {
805837
rs, ok := s.RootModule().Resources[n]

0 commit comments

Comments
 (0)