From 8392f626003bf337f78dbe43cc99414026109b08 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Mon, 4 Dec 2023 22:46:52 +0100 Subject: [PATCH] chore: change region used in online archive process region to one supported in cloud dev (#1703) * chore: change region used in online archive process region to one supported in cloud dev * add test for case when unkown region is provided --- mongodbatlas/resource_online_archive_test.go | 36 ++++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/mongodbatlas/resource_online_archive_test.go b/mongodbatlas/resource_online_archive_test.go index bc05b259ff..dd95d6e179 100644 --- a/mongodbatlas/resource_online_archive_test.go +++ b/mongodbatlas/resource_online_archive_test.go @@ -179,6 +179,7 @@ func TestAccBackupRSOnlineArchiveWithProcessRegion(t *testing.T) { projectName = acctest.RandomWithPrefix("test-acc") name = fmt.Sprintf("test-acc-%s", acctest.RandString(10)) cloudProvider = "AWS" + processRegion = "US_EAST_1" ) resource.ParallelTest(t, resource.TestCase{ @@ -195,12 +196,12 @@ func TestAccBackupRSOnlineArchiveWithProcessRegion(t *testing.T) { ), }, { - Config: testAccBackupRSOnlineArchiveConfigWithProcessRegion(orgID, projectName, name, cloudProvider, "SA_EAST_1"), + Config: testAccBackupRSOnlineArchiveConfigWithProcessRegion(orgID, projectName, name, cloudProvider, processRegion), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(onlineArchiveResourceName, "data_process_region.0.cloud_provider", "AWS"), - resource.TestCheckResourceAttr(onlineArchiveResourceName, "data_process_region.0.region", "SA_EAST_1"), - resource.TestCheckResourceAttr(onlineArchiveDataSourceName, "data_process_region.0.cloud_provider", "AWS"), - resource.TestCheckResourceAttr(onlineArchiveDataSourceName, "data_process_region.0.region", "SA_EAST_1"), + resource.TestCheckResourceAttr(onlineArchiveResourceName, "data_process_region.0.cloud_provider", cloudProvider), + resource.TestCheckResourceAttr(onlineArchiveResourceName, "data_process_region.0.region", processRegion), + resource.TestCheckResourceAttr(onlineArchiveDataSourceName, "data_process_region.0.cloud_provider", cloudProvider), + resource.TestCheckResourceAttr(onlineArchiveDataSourceName, "data_process_region.0.region", processRegion), ), }, { @@ -210,14 +211,35 @@ func TestAccBackupRSOnlineArchiveWithProcessRegion(t *testing.T) { { Config: testAccBackupRSOnlineArchiveConfigWithoutSchedule(orgID, projectName, name), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(onlineArchiveResourceName, "data_process_region.0.cloud_provider", "AWS"), - resource.TestCheckResourceAttr(onlineArchiveResourceName, "data_process_region.0.region", "SA_EAST_1"), + resource.TestCheckResourceAttr(onlineArchiveResourceName, "data_process_region.0.cloud_provider", cloudProvider), + resource.TestCheckResourceAttr(onlineArchiveResourceName, "data_process_region.0.region", processRegion), ), }, }, }) } +func TestAccBackupRSOnlineArchiveInvalidProcessRegion(t *testing.T) { + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acctest.RandomWithPrefix("test-acc") + name = fmt.Sprintf("test-acc-%s", acctest.RandString(10)) + cloudProvider = "AWS" + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acc.PreCheckBasic(t) }, + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccBackupRSOnlineArchiveConfigWithProcessRegion(orgID, projectName, name, cloudProvider, "UNKNOWN"), + ExpectError: regexp.MustCompile("INVALID_ATTRIBUTE"), + }, + }, + }) +} + func populateWithSampleData(resourceName string, cluster *matlas.Cluster) resource.TestCheckFunc { return func(s *terraform.State) error { conn := acc.TestMongoDBClient.(*config.MongoDBClient).Atlas