@@ -7,7 +7,10 @@ import (
77 "testing"
88
99 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
10+ "github.com/hashicorp/terraform-plugin-testing/knownvalue"
11+ "github.com/hashicorp/terraform-plugin-testing/statecheck"
1012 "github.com/hashicorp/terraform-plugin-testing/terraform"
13+ "github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
1114 "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
1215 "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate"
1316 "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
@@ -35,10 +38,28 @@ func TestAccApiKeyProjectAssignmentRS_basic(t *testing.T) {
3538 {
3639 Config : apiKeyProjectAssignmentConfig (orgID , roleName , projectName ),
3740 Check : apiKeyProjectAssignmentAttributeChecks (),
41+ ConfigStateChecks : []statecheck.StateCheck {
42+ statecheck .ExpectKnownValue (
43+ resourceName ,
44+ tfjsonpath .New ("roles" ),
45+ knownvalue .SetExact ([]knownvalue.Check {
46+ knownvalue .StringExact (roleName ),
47+ }),
48+ ),
49+ },
3850 },
3951 {
4052 Config : apiKeyProjectAssignmentConfig (orgID , roleNameUpdated , projectName ),
4153 Check : apiKeyProjectAssignmentAttributeChecks (),
54+ ConfigStateChecks : []statecheck.StateCheck {
55+ statecheck .ExpectKnownValue (
56+ resourceName ,
57+ tfjsonpath .New ("roles" ),
58+ knownvalue .SetExact ([]knownvalue.Check {
59+ knownvalue .StringExact (roleNameUpdated ),
60+ }),
61+ ),
62+ },
4263 },
4364 {
4465 Config : apiKeyProjectAssignmentConfig (orgID , roleNameUpdated , projectName ),
@@ -66,7 +87,7 @@ func apiKeyProjectAssignmentAttributeChecks() resource.TestCheckFunc {
6687 attrsMap := map [string ]string {
6788 "roles.#" : "1" ,
6889 }
69- attrsSet := []string {"project_id" , "api_key_id" , "roles.0" }
90+ attrsSet := []string {"project_id" , "api_key_id" }
7091 checks := []resource.TestCheckFunc {
7192 checkExists (resourceName ),
7293 }
0 commit comments