Skip to content

Commit b466172

Browse files
committed
Updates TestAccIAMRole_Identity_ExistingResource_NoRefresh_WithChange test with ConfigPlanChecks and ConfigStateChecks
1 parent 60c53d1 commit b466172

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

internal/service/iam/role_test.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ import (
1515
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
1616
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1717
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
18+
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
1819
"github.com/hashicorp/terraform-plugin-testing/plancheck"
20+
"github.com/hashicorp/terraform-plugin-testing/statecheck"
1921
"github.com/hashicorp/terraform-plugin-testing/terraform"
22+
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
2023
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
24+
tfknownvalue "github.com/hashicorp/terraform-provider-aws/internal/acctest/knownvalue"
25+
tfstatecheck "github.com/hashicorp/terraform-provider-aws/internal/acctest/statecheck"
2126
"github.com/hashicorp/terraform-provider-aws/internal/conns"
2227
"github.com/hashicorp/terraform-provider-aws/internal/errs"
2328
tfiam "github.com/hashicorp/terraform-provider-aws/internal/service/iam"
@@ -972,7 +977,7 @@ func TestAccIAMRole_ManagedPolicy_outOfBandAdditionRemovedEmpty(t *testing.T) {
972977
})
973978
}
974979

975-
func TestAccIAMRole_Identity_ExistingResource_NoRefresh(t *testing.T) {
980+
func TestAccIAMRole_Identity_ExistingResource_NoRefresh_WithChange(t *testing.T) {
976981
ctx := acctest.Context(t)
977982
var conf awstypes.Role
978983
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
@@ -999,15 +1004,31 @@ func TestAccIAMRole_Identity_ExistingResource_NoRefresh(t *testing.T) {
9991004
Check: resource.ComposeAggregateTestCheckFunc(
10001005
testAccCheckRoleExists(ctx, resourceName, &conf),
10011006
),
1007+
ConfigStateChecks: []statecheck.StateCheck{
1008+
tfstatecheck.ExpectNoIdentity(resourceName),
1009+
},
10021010
},
10031011
{
10041012
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
10051013
Config: testAccRoleConfig_description(rName),
10061014
Check: resource.ComposeAggregateTestCheckFunc(
10071015
testAccCheckRoleExists(ctx, resourceName, &conf),
10081016
),
1009-
// No error indicates the identity interceptor properly identified
1010-
// a fully null identity on update and set values appropriately.
1017+
ConfigPlanChecks: resource.ConfigPlanChecks{
1018+
PreApply: []plancheck.PlanCheck{
1019+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate),
1020+
},
1021+
PostApplyPostRefresh: []plancheck.PlanCheck{
1022+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
1023+
},
1024+
},
1025+
ConfigStateChecks: []statecheck.StateCheck{
1026+
statecheck.ExpectIdentity(resourceName, map[string]knownvalue.Check{
1027+
names.AttrAccountID: tfknownvalue.AccountID(),
1028+
names.AttrName: knownvalue.NotNull(),
1029+
}),
1030+
statecheck.ExpectIdentityValueMatchesState(resourceName, tfjsonpath.New(names.AttrName)),
1031+
},
10111032
},
10121033
},
10131034
})

0 commit comments

Comments
 (0)