Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: : Provider crash when an invalid role name is specified to mongodbatlas_project_api_key #1720

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test
andreaangiolillo committed Dec 7, 2023

Verified

This commit was signed with the committer’s verified signature.
sandhose Quentin Gliech
commit 51f00a46f4b0dd43fc8d28a712272b9abe5a8119
16 changes: 5 additions & 11 deletions internal/service/projectapikey/resource_project_api_key_test.go
Original file line number Diff line number Diff line change
@@ -345,11 +345,10 @@ func testAccCheckMongoDBAtlasProjectAPIKeyDestroy(s *terraform.State) error {

func TestAccConfigRSProjectAPIKey_Invalid_Role(t *testing.T) {
var (
resourceName = "mongodbatlas_project_api_key.test"
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acctest.RandomWithPrefix("test-acc")
description = fmt.Sprintf("test-acc-project-api_key-%s", acctest.RandString(5))
roleName = "INVALID_ROLE"
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acctest.RandomWithPrefix("test-acc")
description = projectName
roleName = "INVALID_ROLE"
)

resource.ParallelTest(t, resource.TestCase{
@@ -358,12 +357,7 @@ func TestAccConfigRSProjectAPIKey_Invalid_Role(t *testing.T) {
CheckDestroy: testAccCheckMongoDBAtlasProjectAPIKeyDestroy,
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasProjectAPIKeyConfigBasic(orgID, projectName, description, roleName, false),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "description", description),
resource.TestCheckResourceAttrSet(resourceName, "public_key"),
resource.TestCheckResourceAttr(resourceName, "project_assignment.#", "1"),
),
Config: testAccMongoDBAtlasProjectAPIKeyConfigBasic(orgID, projectName, description, roleName, false),
ExpectError: regexp.MustCompile("INVALID_ENUM_VALUE"),
},
},