Skip to content

Commit

Permalink
chore: change region used in online archive process region to one sup…
Browse files Browse the repository at this point in the history
…ported 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
  • Loading branch information
AgustinBettati authored Dec 4, 2023
1 parent 09730f0 commit 8392f62
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions mongodbatlas/resource_online_archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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),
),
},
{
Expand All @@ -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
Expand Down

0 comments on commit 8392f62

Please sign in to comment.