-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue in switch back test error messages changed in Terraform v1.6
SwitchBackToRemoteFuncError tests verify error messages, but the error message for missing bucket key in the s3 backend differs depending on the Terraform version. Define a helper function to hide the difference.
- Loading branch information
1 parent
7591205
commit ae31322
Showing
3 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package tfmigrate | ||
|
||
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. | ||
// Define a helper function to hide the difference. | ||
// | ||
// # Terraform v1.5 | ||
// | ||
// ``` | ||
// Error: "bucket": required field is not set | ||
// ``` | ||
// | ||
// # Terraform v1.6 | ||
// | ||
// ``` | ||
// | ||
// Error: Missing Required Value | ||
// | ||
// on main.tf line 4, in terraform: | ||
// 4: backend "s3" { | ||
// | ||
// The attribute "bucket" is required by the backend. | ||
// | ||
// Refer to the backend documentation for additional information which | ||
// attributes are required. | ||
// | ||
// ``` | ||
const testBucketRequiredErrorLegacyTF = `Error: "bucket": required field is not set` | ||
const testBucketRequiredErrorTF16 = `The attribute "bucket" is required by the backend` | ||
|
||
var testBucketRequiredErrorRE = regexp.MustCompile(testBucketRequiredErrorLegacyTF + `|` + testBucketRequiredErrorTF16) | ||
|
||
func containsBucketRequiredError(err error) bool { | ||
return testBucketRequiredErrorRE.MatchString(err.Error()) | ||
} |