Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable ServiceCatalog Provisioned Product product_name update test until v5 #31115

Merged
merged 1 commit into from
May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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