Skip to content

Commit

Permalink
feat: fixes region and aws account to be used for trigger acc test (#…
Browse files Browse the repository at this point in the history
…1558)

* fixes region and aws account to be used for eventbridge trigger creation.

* addresses comments.

* addresses comments.

* addresses comments.

* removes skip test rule.

* Revert "removes skip test rule."

This reverts commit 5670d0a.
  • Loading branch information
marcosuma authored Oct 30, 2023
1 parent 6df6ad6 commit 7ba7282
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions mongodbatlas/resource_mongodbatlas_event_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/util"
"github.com/mwielbut/pointy"
"go.mongodb.org/realm/realm"
)
Expand Down Expand Up @@ -80,12 +81,12 @@ func TestAccConfigRSEventTriggerDatabase_basic(t *testing.T) {
func TestAccConfigRSEventTriggerDatabase_eventProccesor(t *testing.T) {
SkipTestForCI(t)
var (
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
awsAccountID = os.Getenv("AWS_ACCOUNT_ID")
awsRegion = os.Getenv("AWS_REGION")
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
eventBridgeAwsAccountID = os.Getenv("AWS_EVENTBRIDGE_ACCOUNT_ID")
eventBridgeAwsRegion = util.MongoDBRegionToAWSRegion(os.Getenv("AWS_REGION"))
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
)
event := realm.EventTriggerRequest{
Name: acctest.RandomWithPrefix("test-acc"),
Expand Down Expand Up @@ -120,14 +121,14 @@ func TestAccConfigRSEventTriggerDatabase_eventProccesor(t *testing.T) {
CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabaseEP(projectID, appID, `"INSERT", "UPDATE"`, awsAccountID, awsRegion, &event),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabaseEP(projectID, appID, `"INSERT", "UPDATE"`, eventBridgeAwsAccountID, eventBridgeAwsRegion, &event),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
),
},
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabaseEP(projectID, appID, `"INSERT", "UPDATE", "DELETE"`, awsAccountID, awsRegion, &eventUpdated),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabaseEP(projectID, appID, `"INSERT", "UPDATE", "DELETE"`, eventBridgeAwsAccountID, eventBridgeAwsRegion, &eventUpdated),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
Expand Down Expand Up @@ -205,12 +206,12 @@ func TestAccConfigRSEventTriggerAuth_basic(t *testing.T) {
func TestAccConfigRSEventTriggerAuth_eventProcessor(t *testing.T) {
SkipTestForCI(t)
var (
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
awsAccountID = os.Getenv("AWS_ACCOUNT_ID")
awsRegion = os.Getenv("AWS_REGION")
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
eventBridgeAwsAccountID = os.Getenv("AWS_EVENTBRIDGE_ACCOUNT_ID")
eventBridgeAwsRegion = util.MongoDBRegionToAWSRegion(os.Getenv("AWS_REGION"))
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
)
event := realm.EventTriggerRequest{
Name: acctest.RandomWithPrefix("test-acc"),
Expand Down Expand Up @@ -240,14 +241,14 @@ func TestAccConfigRSEventTriggerAuth_eventProcessor(t *testing.T) {
CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthenticationEP(projectID, appID, `"anon-user", "local-userpass"`, awsAccountID, awsRegion, &event),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthenticationEP(projectID, appID, `"anon-user", "local-userpass"`, eventBridgeAwsAccountID, eventBridgeAwsRegion, &event),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
),
},
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthenticationEP(projectID, appID, `"anon-user", "local-userpass", "api-key"`, awsAccountID, awsRegion, &eventUpdated),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthenticationEP(projectID, appID, `"anon-user", "local-userpass", "api-key"`, eventBridgeAwsAccountID, eventBridgeAwsRegion, &eventUpdated),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
Expand Down Expand Up @@ -322,12 +323,12 @@ func TestAccConfigRSEventTriggerSchedule_basic(t *testing.T) {
func TestAccConfigRSEventTriggerSchedule_eventProcessor(t *testing.T) {
SkipTestForCI(t)
var (
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
awsAccountID = os.Getenv("AWS_ACCOUNT_ID")
awsRegion = os.Getenv("AWS_REGION")
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
eventBridgeAwsAccountID = os.Getenv("AWS_EVENTBRIDGE_ACCOUNT_ID")
eventBridgeAwsRegion = util.MongoDBRegionToAWSRegion(os.Getenv("AWS_REGION"))
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
)
event := realm.EventTriggerRequest{
Name: acctest.RandomWithPrefix("test-acc"),
Expand All @@ -354,14 +355,14 @@ func TestAccConfigRSEventTriggerSchedule_eventProcessor(t *testing.T) {
CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigScheduleEP(projectID, appID, awsAccountID, awsRegion, &event),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigScheduleEP(projectID, appID, eventBridgeAwsAccountID, eventBridgeAwsRegion, &event),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
),
},
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigScheduleEP(projectID, appID, awsAccountID, awsRegion, &eventUpdated),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigScheduleEP(projectID, appID, eventBridgeAwsAccountID, eventBridgeAwsRegion, &eventUpdated),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
Expand Down

0 comments on commit 7ba7282

Please sign in to comment.