diff --git a/Makefile b/Makefile index 48c2b148..8808f8da 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ setup: acctest: # TEST_FILTER can be any regex, E.g: .*PageResource.* # TEST_FILTER='TestAccPortPageResource*' make acctest - TF_ACC=1 PORT_CLIENT_ID=$(PORT_CLIENT_ID) PORT_CLIENT_SECRET=$(PORT_CLIENT_SECRET) PORT_BASE_URL=$(PORT_BASE_URL) go test -p 1 ./... -run "$(TEST_FILTER)" + TF_ACC=1 PORT_CLIENT_ID=$(PORT_CLIENT_ID) PORT_CLIENT_SECRET=$(PORT_CLIENT_SECRET) PORT_BASE_URL=$(PORT_BASE_URL) go test -timeout 20m -p 1 ./... -run "$(TEST_FILTER)" gen-docs: tfplugindocs diff --git a/port/action/resource_test.go b/port/action/resource_test.go index a5489521..7fd8b049 100644 --- a/port/action/resource_test.go +++ b/port/action/resource_test.go @@ -1570,11 +1570,12 @@ func TestAccPortAutomationTimerPropertyExpired(t *testing.T) { func TestAccPortAutomationRunCreated(t *testing.T) { identifier := utils.GenID() - actionIdentifier := utils.GenID() + mainActionIdentifier := utils.GenID() + relatedActionIdentifier := utils.GenID() var testAccActionConfigCreate = testAccCreateBlueprintConfig(identifier) + fmt.Sprintf(` resource "port_action" "self_serve_action" { title = "self serve action" - identifier = "self_serve_action" + identifier = "%s" icon = "Terraform" self_service_trigger = { operation = "CREATE" @@ -1590,12 +1591,12 @@ func TestAccPortAutomationRunCreated(t *testing.T) { icon = "Terraform" automation_trigger = { run_created_event = { - action_identifier = "self_serve_action" + action_identifier = "%s" } } kafka_method = {} depends_on = [port_action.self_serve_action] - }`, actionIdentifier) + }`, relatedActionIdentifier, mainActionIdentifier, relatedActionIdentifier) resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.TestAccPreCheck(t) }, ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, @@ -1604,16 +1605,16 @@ func TestAccPortAutomationRunCreated(t *testing.T) { Config: acctest.ProviderConfig + testAccActionConfigCreate, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("port_action.create_microservice", "title", "TF Provider Test"), - resource.TestCheckResourceAttr("port_action.create_microservice", "identifier", actionIdentifier), + resource.TestCheckResourceAttr("port_action.create_microservice", "identifier", mainActionIdentifier), resource.TestCheckResourceAttr("port_action.create_microservice", "icon", "Terraform"), - resource.TestCheckResourceAttr("port_action.create_microservice", "automation_trigger.run_created_event.action_identifier", "self_serve_action"), + resource.TestCheckResourceAttr("port_action.create_microservice", "automation_trigger.run_created_event.action_identifier", relatedActionIdentifier), ), }, { ResourceName: "port_action.create_microservice", ImportState: true, ImportStateVerify: true, - ImportStateId: actionIdentifier, + ImportStateId: mainActionIdentifier, }, }, }) @@ -1621,11 +1622,12 @@ func TestAccPortAutomationRunCreated(t *testing.T) { func TestAccPortAutomationRunUpdated(t *testing.T) { identifier := utils.GenID() - actionIdentifier := utils.GenID() + mainActionIdentifier := utils.GenID() + relatedActionIdentifier := utils.GenID() var testAccActionConfigCreate = testAccCreateBlueprintConfig(identifier) + fmt.Sprintf(` resource "port_action" "self_serve_action" { title = "self serve action" - identifier = "self_serve_action" + identifier = "%s" icon = "Terraform" self_service_trigger = { operation = "CREATE" @@ -1641,12 +1643,12 @@ func TestAccPortAutomationRunUpdated(t *testing.T) { icon = "Terraform" automation_trigger = { run_updated_event = { - action_identifier = "self_serve_action" + action_identifier = "%s" } } kafka_method = {} depends_on = [port_action.self_serve_action] - }`, actionIdentifier) + }`, relatedActionIdentifier, mainActionIdentifier, relatedActionIdentifier) resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.TestAccPreCheck(t) }, ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, @@ -1655,16 +1657,16 @@ func TestAccPortAutomationRunUpdated(t *testing.T) { Config: acctest.ProviderConfig + testAccActionConfigCreate, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("port_action.create_microservice", "title", "TF Provider Test"), - resource.TestCheckResourceAttr("port_action.create_microservice", "identifier", actionIdentifier), + resource.TestCheckResourceAttr("port_action.create_microservice", "identifier", mainActionIdentifier), resource.TestCheckResourceAttr("port_action.create_microservice", "icon", "Terraform"), - resource.TestCheckResourceAttr("port_action.create_microservice", "automation_trigger.run_updated_event.action_identifier", "self_serve_action"), + resource.TestCheckResourceAttr("port_action.create_microservice", "automation_trigger.run_updated_event.action_identifier", relatedActionIdentifier), ), }, { ResourceName: "port_action.create_microservice", ImportState: true, ImportStateVerify: true, - ImportStateId: actionIdentifier, + ImportStateId: mainActionIdentifier, }, }, }) @@ -1672,11 +1674,12 @@ func TestAccPortAutomationRunUpdated(t *testing.T) { func TestAccPortAutomationAnyRunChange(t *testing.T) { identifier := utils.GenID() - actionIdentifier := utils.GenID() + mainActionIdentifier := utils.GenID() + relatedActionIdentifier := utils.GenID() var testAccActionConfigCreate = testAccCreateBlueprintConfig(identifier) + fmt.Sprintf(` resource "port_action" "self_serve_action" { title = "self serve action" - identifier = "self_serve_action" + identifier = "%s" icon = "Terraform" self_service_trigger = { operation = "CREATE" @@ -1692,12 +1695,12 @@ func TestAccPortAutomationAnyRunChange(t *testing.T) { icon = "Terraform" automation_trigger = { any_run_change_event = { - action_identifier = "self_serve_action" + action_identifier = "%s" } } kafka_method = {} depends_on = [port_action.self_serve_action] - }`, actionIdentifier) + }`, relatedActionIdentifier, mainActionIdentifier, relatedActionIdentifier) resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.TestAccPreCheck(t) }, ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, @@ -1706,16 +1709,16 @@ func TestAccPortAutomationAnyRunChange(t *testing.T) { Config: acctest.ProviderConfig + testAccActionConfigCreate, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("port_action.create_microservice", "title", "TF Provider Test"), - resource.TestCheckResourceAttr("port_action.create_microservice", "identifier", actionIdentifier), + resource.TestCheckResourceAttr("port_action.create_microservice", "identifier", mainActionIdentifier), resource.TestCheckResourceAttr("port_action.create_microservice", "icon", "Terraform"), - resource.TestCheckResourceAttr("port_action.create_microservice", "automation_trigger.any_run_change_event.action_identifier", "self_serve_action"), + resource.TestCheckResourceAttr("port_action.create_microservice", "automation_trigger.any_run_change_event.action_identifier", relatedActionIdentifier), ), }, { ResourceName: "port_action.create_microservice", ImportState: true, ImportStateVerify: true, - ImportStateId: actionIdentifier, + ImportStateId: mainActionIdentifier, }, }, }) diff --git a/port/blueprint/readStateToPortBody.go b/port/blueprint/readStateToPortBody.go index 2065e377..8fed31be 100644 --- a/port/blueprint/readStateToPortBody.go +++ b/port/blueprint/readStateToPortBody.go @@ -3,6 +3,7 @@ package blueprint import ( "context" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/port-labs/terraform-provider-port-labs/v2/internal/cli" ) @@ -130,7 +131,9 @@ func calculationPropertiesToBody(ctx context.Context, state *BlueprintModel) map if !prop.Colors.IsNull() { colors := make(map[string]string) for key, value := range prop.Colors.Elements() { - colors[key] = value.String() + if stringValue, ok := value.(basetypes.StringValue); ok { + colors[key] = stringValue.ValueString() + } } calculationProp.Colors = colors diff --git a/port/blueprint/resource_test.go b/port/blueprint/resource_test.go index dea94683..d0a15bb5 100644 --- a/port/blueprint/resource_test.go +++ b/port/blueprint/resource_test.go @@ -672,6 +672,12 @@ func TestAccPortBlueprintWithCalculationProperty(t *testing.T) { calculation = "test-rel.$identifier" type = "string" icon = "Terraform" + colors = { + "test1" = "red" + "test2" = "blue" + "test3" = "green" + "test4" = "yellow" + } } } }`, identifier1) @@ -686,6 +692,7 @@ func TestAccPortBlueprintWithCalculationProperty(t *testing.T) { resource.TestCheckResourceAttr("port_blueprint.microservice1", "calculation_properties.calculation-for-microservice1.title", "Calculation for microservice1"), resource.TestCheckResourceAttr("port_blueprint.microservice1", "calculation_properties.calculation-for-microservice1.calculation", "test-rel.$identifier"), resource.TestCheckResourceAttr("port_blueprint.microservice1", "calculation_properties.calculation-for-microservice1.icon", "Terraform"), + resource.TestCheckResourceAttr("port_blueprint.microservice1", "calculation_properties.calculation-for-microservice1.colors.test2", "blue"), ), }, }, @@ -885,7 +892,7 @@ func TestAccPortBlueprintCatalogPageCreation(t *testing.T) { } // give grace time for page creation - time.Sleep(3 * time.Second) + time.Sleep(10 * time.Second) _, statusCode, err := portClient.GetPage(ctx, identifier) if err != nil {