99 "testing"
1010
1111 "github.com/aws/aws-sdk-go-v2/service/identitystore"
12+ "github.com/hashicorp/terraform-plugin-testing/compare"
1213 sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1314 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
1415 "github.com/hashicorp/terraform-plugin-testing/knownvalue"
@@ -17,6 +18,7 @@ import (
1718 "github.com/hashicorp/terraform-plugin-testing/terraform"
1819 "github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
1920 "github.com/hashicorp/terraform-provider-aws/internal/acctest"
21+ tfstatecheck "github.com/hashicorp/terraform-provider-aws/internal/acctest/statecheck"
2022 "github.com/hashicorp/terraform-provider-aws/internal/conns"
2123 tfidentitystore "github.com/hashicorp/terraform-provider-aws/internal/service/identitystore"
2224 "github.com/hashicorp/terraform-provider-aws/internal/tfresource"
@@ -42,9 +44,11 @@ func TestAccIdentityStoreGroup_basic(t *testing.T) {
4244 {
4345 Config : testAccGroupConfig_basic (displayName ),
4446 ConfigStateChecks : []statecheck.StateCheck {
47+ tfstatecheck .ExpectGlobalARNNoAccountIDFormat (resourceName , tfjsonpath .New (names .AttrARN ), "identitystore" , "group/{group_id}" ),
48+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New (names .AttrDescription ), knownvalue .StringExact ("" )),
4549 statecheck .ExpectKnownValue (resourceName , tfjsonpath .New (names .AttrDisplayName ), knownvalue .StringExact (displayName )),
4650 statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("group_id" ), knownvalue .NotNull ()),
47- statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("identity_store_id" ), knownvalue . NotNull ()),
51+ statecheck .CompareValuePairs (resourceName , tfjsonpath .New ("identity_store_id" ), "data.aws_ssoadmin_instances.test" , tfjsonpath . New ( "identity_store_ids" ). AtSliceIndex ( 0 ), compare . ValuesSame ()),
4852 },
4953 Check : resource .ComposeTestCheckFunc (
5054 testAccCheckGroupExists (ctx , resourceName , & group ),
@@ -234,33 +238,35 @@ func testAccCheckGroupExists(ctx context.Context, n string, v *identitystore.Des
234238
235239func testAccGroupConfig_basic (displayName string ) string {
236240 return fmt .Sprintf (`
237- data "aws_ssoadmin_instances" "test" {}
238241resource "aws_identitystore_group" "test" {
239- identity_store_id = tolist( data.aws_ssoadmin_instances.test.identity_store_ids) [0]
242+ identity_store_id = data.aws_ssoadmin_instances.test.identity_store_ids[0]
240243 display_name = %[1]q
241- description = "Example description"
242244}
245+
246+ data "aws_ssoadmin_instances" "test" {}
243247` , displayName )
244248}
245249
246250func testAccGroupConfig_description (description string ) string {
247251 return fmt .Sprintf (`
248- data "aws_ssoadmin_instances" "test" {}
249252resource "aws_identitystore_group" "test" {
250253 identity_store_id = tolist(data.aws_ssoadmin_instances.test.identity_store_ids)[0]
251254 display_name = "Test display name"
252255 description = %[1]q
253256}
257+
258+ data "aws_ssoadmin_instances" "test" {}
254259` , description )
255260}
256261
257262func testAccGroupConfig_displayName (displayName string ) string {
258263 return fmt .Sprintf (`
259- data "aws_ssoadmin_instances" "test" {}
260264resource "aws_identitystore_group" "test" {
261265 identity_store_id = tolist(data.aws_ssoadmin_instances.test.identity_store_ids)[0]
262266 display_name = %[1]q
263267 description = "Test description"
264268}
269+
270+ data "aws_ssoadmin_instances" "test" {}
265271` , displayName )
266272}
0 commit comments