From be2841a0c4975d63f72239f93720a2c1a891410f Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Thu, 9 Nov 2023 10:31:34 +0900 Subject: [PATCH] Fixed parsing of error messages in tests Slightly different error messages in Terraform v1.6 and OpenTofu v1.6. --- tfmigrate/test_helper.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tfmigrate/test_helper.go b/tfmigrate/test_helper.go index 1660adc..1f994f0 100644 --- a/tfmigrate/test_helper.go +++ b/tfmigrate/test_helper.go @@ -4,12 +4,16 @@ import "regexp" // SwitchBackToRemoteFuncError tests verify error messages, but the // error message for missing bucket key in the s3 backend differs -// depending on the Terraform version. +// depending on the Terraform version and OpenTofu version. // Define a helper function to hide the difference. -const testBucketRequiredErrorLegacyTF = `Error: "bucket": required field is not set` -const testBucketRequiredErrorTF16 = `The attribute "bucket" is required by the backend` +const testBucketRequiredErrorLegacyTerraform = `Error: "bucket": required field is not set` +const testBucketRequiredErrorTerraform16 = `The attribute "bucket" is required by the backend` +const testBucketRequiredErrorOpenTofu16 = `The "bucket" attribute value must not be empty` -var testBucketRequiredErrorRE = regexp.MustCompile(testBucketRequiredErrorLegacyTF + `|` + testBucketRequiredErrorTF16) +var testBucketRequiredErrorRE = regexp.MustCompile( + testBucketRequiredErrorLegacyTerraform + `|` + + testBucketRequiredErrorTerraform16 + `|` + + testBucketRequiredErrorOpenTofu16) func containsBucketRequiredError(err error) bool { return testBucketRequiredErrorRE.MatchString(err.Error())