66 "os"
77 "testing"
88
9+ "github.com/gruntwork-io/terratest/modules/logger"
10+ "github.com/gruntwork-io/terratest/modules/terraform"
911 "github.com/stretchr/testify/assert"
1012 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common"
1113 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
@@ -150,7 +152,7 @@ func TestRunSolutionsFullyConfigurableUpgradeSchematics(t *testing.T) {
150152 {Name : "prefix" , Value : options .Prefix , DataType : "string" },
151153 {Name : "existing_secrets_manager_crn" , Value : permanentResources ["secretsManagerCRN" ], DataType : "string" },
152154 {Name : "acme_letsencrypt_private_key_secrets_manager_secret_crn" , Value : permanentResources ["acme_letsencrypt_private_key_secret_crn" ], DataType : "string" },
153- {Name : "dns_config_name" , Value : "cert -dns" , DataType : "string" },
155+ {Name : "dns_config_name" , Value : "cer -dns" , DataType : "string" },
154156 {Name : "internet_services_crn" , Value : permanentResources ["cisInstanceId" ], DataType : "string" },
155157 {Name : "skip_iam_authorization_policy" , Value : true , DataType : "bool" }, // A permanent cis-sm auth policy already exists in the account
156158 }
@@ -160,3 +162,32 @@ func TestRunSolutionsFullyConfigurableUpgradeSchematics(t *testing.T) {
160162 assert .Nil (t , err , "This should not have errored" )
161163 }
162164}
165+
166+ func TestPlanValidation (t * testing.T ) {
167+
168+ options := testhelper .TestOptionsDefault (& testhelper.TestOptions {
169+ Testing : t ,
170+ TerraformDir : fullyConfigurableDir ,
171+ Prefix : "val-plan" ,
172+ ResourceGroup : resourceGroup ,
173+ })
174+ options .TestSetup ()
175+ options .TerraformOptions .NoColor = true
176+ options .TerraformOptions .Logger = logger .Discard
177+ options .TerraformOptions .Vars = map [string ]interface {}{
178+ "prefix" : options .Prefix ,
179+ "existing_secrets_manager_crn" : permanentResources ["secretsManagerCRN" ],
180+ "acme_letsencrypt_private_key" : "PRIVATE_KEY_VALUE" , // pragma: allowlist secret
181+ "skip_iam_authorization_policy" : true ,
182+ "provider_visibility" : "public" ,
183+ }
184+
185+ // Init
186+ _ , initErr := terraform .InitE (t , options .TerraformOptions )
187+ assert .Nil (t , initErr , "Terraform init should not error" )
188+
189+ // Plan
190+ planOutput , planErr := terraform .PlanE (t , options .TerraformOptions )
191+ assert .Nil (t , planErr , "Terraform plan should not error" )
192+ assert .NotNil (t , planOutput , "Expected Terraform plan output" )
193+ }
0 commit comments