From 2a97b81de1608b39da7919e6e133b6c547a319b2 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 2 Jan 2024 16:00:29 +0100 Subject: [PATCH] website: Use ConfigPlanChecks instead of PlanOnly in migration testing (#899) Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/256 --- .../plugin/framework/migrating/testing.mdx | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/website/docs/plugin/framework/migrating/testing.mdx b/website/docs/plugin/framework/migrating/testing.mdx index a54cb8f95..843772c6f 100644 --- a/website/docs/plugin/framework/migrating/testing.mdx +++ b/website/docs/plugin/framework/migrating/testing.mdx @@ -38,7 +38,7 @@ and then verify that there are no planned changes after migrating to the Framewo - The first `TestStep` uses `ExternalProviders` to cause `terraform apply` to execute with a previous version of the provider, which is built on SDKv2. - The second `TestStep` uses `ProtoV5ProviderFactories` so that the test uses the provider code contained within the -provider repository. The second step also uses `PlanOnly` to verify that a no-op plan is generated. +provider repository. The second step uses `ConfigPlanChecks` to verify that a no-op plan is generated. #### Managed Resource @@ -69,7 +69,16 @@ func TestResource_UpgradeFromVersion(t *testing.T) { Config: `resource "provider_resource" "example" { /* ... */ }`, - PlanOnly: true, + // ConfigPlanChecks is a terraform-plugin-testing feature. + // If acceptance testing is still using terraform-plugin-sdk/v2, + // use `PlanOnly: true` instead. When migrating to + // terraform-plugin-testing, switch to `ConfigPlanChecks` or you + // will likely experience test failures. + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectEmptyPlan(), + }, + }, }, }, }) @@ -117,7 +126,16 @@ func TestDataSource_UpgradeFromVersion(t *testing.T) { resource "terraform_data" "test" { input = data.provider_datasource.test }`, - PlanOnly: true, + // ConfigPlanChecks is a terraform-plugin-testing feature. + // If acceptance testing is still using terraform-plugin-sdk/v2, + // use `PlanOnly: true` instead. When migrating to + // terraform-plugin-testing, switch to `ConfigPlanChecks` or you + // will likely experience test failures. + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectEmptyPlan(), + }, + }, }, }, })