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

tests/provider: Use string matching in testAccErrorCheckCommon() and catch all InvalidAction #18283

Merged
merged 1 commit into from
Mar 19, 2021
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
11 changes: 7 additions & 4 deletions aws/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,9 @@ func testAccErrorCheck(t *testing.T, endpointIDs ...string) resource.ErrorCheckF
}
}

// NOTE: This function cannot use the standard tfawserr helpers
// as it is receiving error strings from the SDK testing framework,
// not actual error types from the resource logic.
func testAccErrorCheckCommon(err error) bool {
if strings.Contains(err.Error(), "is not supported in this") {
return true
Expand All @@ -1119,19 +1122,19 @@ func testAccErrorCheckCommon(err error) bool {
return true
}

if tfawserr.ErrCodeEquals(err, "UnknownOperationException") {
if strings.Contains(err.Error(), "InvalidAction") {
return true
}

if tfawserr.ErrCodeEquals(err, "UnsupportedOperation") {
if strings.Contains(err.Error(), "Unknown operation") {
return true
}

if tfawserr.ErrMessageContains(err, "InvalidInputException", "Unknown operation") {
if strings.Contains(err.Error(), "UnknownOperationException") {
return true
}

if tfawserr.ErrMessageContains(err, "InvalidAction", "Unavailable Operation") {
if strings.Contains(err.Error(), "UnsupportedOperation") {
return true
}

Expand Down