@@ -7,7 +7,10 @@ import (
7
7
"testing"
8
8
9
9
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
10
+ "github.com/hashicorp/terraform-plugin-testing/knownvalue"
11
+ "github.com/hashicorp/terraform-plugin-testing/statecheck"
10
12
"github.com/hashicorp/terraform-plugin-testing/terraform"
13
+ "github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
11
14
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
12
15
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate"
13
16
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
@@ -35,10 +38,28 @@ func TestAccApiKeyProjectAssignmentRS_basic(t *testing.T) {
35
38
{
36
39
Config : apiKeyProjectAssignmentConfig (orgID , roleName , projectName ),
37
40
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
+ },
38
50
},
39
51
{
40
52
Config : apiKeyProjectAssignmentConfig (orgID , roleNameUpdated , projectName ),
41
53
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
+ },
42
63
},
43
64
{
44
65
Config : apiKeyProjectAssignmentConfig (orgID , roleNameUpdated , projectName ),
@@ -66,7 +87,7 @@ func apiKeyProjectAssignmentAttributeChecks() resource.TestCheckFunc {
66
87
attrsMap := map [string ]string {
67
88
"roles.#" : "1" ,
68
89
}
69
- attrsSet := []string {"project_id" , "api_key_id" , "roles.0" }
90
+ attrsSet := []string {"project_id" , "api_key_id" }
70
91
checks := []resource.TestCheckFunc {
71
92
checkExists (resourceName ),
72
93
}
0 commit comments