diff --git a/internal/command/testdata/invalid-backend-configuration/removed-backend-type/main.tf b/internal/command/testdata/invalid-backend-configuration/removed-backend-type/main.tf new file mode 100644 index 0000000000..e03d8009e4 --- /dev/null +++ b/internal/command/testdata/invalid-backend-configuration/removed-backend-type/main.tf @@ -0,0 +1,3 @@ +terraform { + backend "artifactory" {} +} diff --git a/internal/command/validate_test.go b/internal/command/validate_test.go index 34ac6804af..d2ada2ba56 100644 --- a/internal/command/validate_test.go +++ b/internal/command/validate_test.go @@ -726,6 +726,25 @@ func TestValidate_backendBlocks(t *testing.T) { } }) + t.Run("removed backends cause errors with extra info", func(t *testing.T) { + output, code := setupTest(t, "invalid-backend-configuration/removed-backend-type") + if code != 1 { + t.Fatalf("expected an unsuccessful exit code %d\n\n%s", code, output.Stderr()) + } + expectedErrMsgs := []string{ + "Error: Unsupported backend type", + "The \"artifactory\" backend is not supported in Terraform v1.3 or later.", + } + for _, msg := range expectedErrMsgs { + if !strings.Contains(output.Stderr(), msg) { + t.Fatalf("unexpected error content: wanted to include %q, got: %s", + msg, + output.Stderr(), + ) + } + } + }) + // We don't validate using the backend's schema due to potential use of the -backend-config flag. t.Run("unknown attributes are not detected by validate command", func(t *testing.T) { output, code := setupTest(t, "invalid-backend-configuration/unknown-attr")