Skip to content

Commit

Permalink
r/aws_servicecatalog_provisioned_product(test): disable product_name …
Browse files Browse the repository at this point in the history
…update test
  • Loading branch information
jar-b committed May 2, 2023
1 parent b9b1d29 commit 5b95152
Showing 1 changed file with 75 additions and 70 deletions.
145 changes: 75 additions & 70 deletions internal/service/servicecatalog/provisioned_product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,55 +142,60 @@ func TestAccServiceCatalogProvisionedProduct_update(t *testing.T) {
})
}

func TestAccServiceCatalogProvisionedProduct_ProductName_update(t *testing.T) {
ctx := acctest.Context(t)
resourceName := "aws_servicecatalog_provisioned_product.test"

rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
productName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
productNameUpdated := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
domain := fmt.Sprintf("http://%s", acctest.RandomDomainName())
var pprod servicecatalog.ProvisionedProductDetail

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, servicecatalog.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckProvisionedProductDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccProvisionedProductConfig_productName(rName, domain, acctest.DefaultEmailAddress, "10.1.0.0/16", productName),
Check: resource.ComposeTestCheckFunc(
testAccCheckProvisionedProductExists(ctx, resourceName, &pprod),
resource.TestCheckResourceAttrPair(resourceName, "product_name", "aws_servicecatalog_product.test", "name"),
resource.TestCheckResourceAttrPair(resourceName, "product_id", "aws_servicecatalog_product.test", "id"),
),
},
{
// update the product name, but keep provisioned product name as-is to trigger an in-place update
Config: testAccProvisionedProductConfig_productName(rName, domain, acctest.DefaultEmailAddress, "10.1.0.0/16", productNameUpdated),
Check: resource.ComposeTestCheckFunc(
testAccCheckProvisionedProductExists(ctx, resourceName, &pprod),
resource.TestCheckResourceAttrPair(resourceName, "product_name", "aws_servicecatalog_product.test", "name"),
resource.TestCheckResourceAttrPair(resourceName, "product_id", "aws_servicecatalog_product.test", "id"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"accept_language",
"ignore_errors",
"product_name",
"provisioning_artifact_name",
"provisioning_parameters",
"retain_physical_resources",
},
},
},
})
}
// NOTE: This test is dependent on a v5.0.0 feature which fixes how
// products are modified when provisioning_artifact_parameters are
// changed. Once v5.0.0 is released, this test can be re-enabled.
// Ref: https://github.com/hashicorp/terraform-provider-aws/pull/31061
//
// func TestAccServiceCatalogProvisionedProduct_ProductName_update(t *testing.T) {
// ctx := acctest.Context(t)
// resourceName := "aws_servicecatalog_provisioned_product.test"

// rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
// productName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
// productNameUpdated := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
// domain := fmt.Sprintf("http://%s", acctest.RandomDomainName())
// var pprod servicecatalog.ProvisionedProductDetail

// resource.ParallelTest(t, resource.TestCase{
// PreCheck: func() { acctest.PreCheck(ctx, t) },
// ErrorCheck: acctest.ErrorCheck(t, servicecatalog.EndpointsID),
// ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
// CheckDestroy: testAccCheckProvisionedProductDestroy(ctx),
// Steps: []resource.TestStep{
// {
// Config: testAccProvisionedProductConfig_productName(rName, domain, acctest.DefaultEmailAddress, "10.1.0.0/16", productName),
// Check: resource.ComposeTestCheckFunc(
// testAccCheckProvisionedProductExists(ctx, resourceName, &pprod),
// resource.TestCheckResourceAttrPair(resourceName, "product_name", "aws_servicecatalog_product.test", "name"),
// resource.TestCheckResourceAttrPair(resourceName, "product_id", "aws_servicecatalog_product.test", "id"),
// ),
// },
// {
// // update the product name, but keep provisioned product name as-is to trigger an in-place update
// Config: testAccProvisionedProductConfig_productName(rName, domain, acctest.DefaultEmailAddress, "10.1.0.0/16", productNameUpdated),
// Check: resource.ComposeTestCheckFunc(
// testAccCheckProvisionedProductExists(ctx, resourceName, &pprod),
// resource.TestCheckResourceAttrPair(resourceName, "product_name", "aws_servicecatalog_product.test", "name"),
// resource.TestCheckResourceAttrPair(resourceName, "product_id", "aws_servicecatalog_product.test", "id"),
// ),
// },
// {
// ResourceName: resourceName,
// ImportState: true,
// ImportStateVerify: true,
// ImportStateVerifyIgnore: []string{
// "accept_language",
// "ignore_errors",
// "product_name",
// "provisioning_artifact_name",
// "provisioning_parameters",
// "retain_physical_resources",
// },
// },
// },
// })
// }

// Reference: https://github.com/hashicorp/terraform-provider-aws/issues/26271
func TestAccServiceCatalogProvisionedProduct_ProvisioningArtifactName_update(t *testing.T) {
Expand Down Expand Up @@ -720,27 +725,27 @@ resource "aws_servicecatalog_provisioned_product" "test" {
`, rName, vpcCidr))
}

func testAccProvisionedProductConfig_productName(rName, domain, email, vpcCidr, productName string) string {
return acctest.ConfigCompose(testAccProvisionedProductTemplateURLBaseConfig(productName, domain, email),
fmt.Sprintf(`
resource "aws_servicecatalog_provisioned_product" "test" {
name = %[1]q
product_name = aws_servicecatalog_product.test.name
provisioning_artifact_name = aws_servicecatalog_product.test.provisioning_artifact_parameters[0].name
path_id = data.aws_servicecatalog_launch_paths.test.summaries[0].path_id
provisioning_parameters {
key = "VPCPrimaryCIDR"
value = %[2]q
}
provisioning_parameters {
key = "LeaveMeEmpty"
value = ""
}
}
`, rName, vpcCidr))
}
// func testAccProvisionedProductConfig_productName(rName, domain, email, vpcCidr, productName string) string {
// return acctest.ConfigCompose(testAccProvisionedProductTemplateURLBaseConfig(productName, domain, email),
// fmt.Sprintf(`
// resource "aws_servicecatalog_provisioned_product" "test" {
// name = %[1]q
// product_name = aws_servicecatalog_product.test.name
// provisioning_artifact_name = aws_servicecatalog_product.test.provisioning_artifact_parameters[0].name
// path_id = data.aws_servicecatalog_launch_paths.test.summaries[0].path_id

// provisioning_parameters {
// key = "VPCPrimaryCIDR"
// value = %[2]q
// }

// provisioning_parameters {
// key = "LeaveMeEmpty"
// value = ""
// }
// }
// `, rName, vpcCidr))
// }

func testAccProvisionedProductConfig_ProvisionedArtifactName_update(rName, domain, email, vpcCidr, artifactName string) string {
return acctest.ConfigCompose(testAccProvisionedProductTemplateURLBaseConfig(rName, domain, email),
Expand Down

0 comments on commit 5b95152

Please sign in to comment.