diff --git a/META.d/_summary.yaml b/META.d/_summary.yaml new file mode 100644 index 000000000..56ab752a7 --- /dev/null +++ b/META.d/_summary.yaml @@ -0,0 +1,10 @@ +--- +schema: 1.1 + +partition: tf-ecosystem + +summary: + owner: team-tf-core-plugins + description: | + Module for testing Terraform providers + visibility: public diff --git a/helper/resource/testing.go b/helper/resource/testing.go index 0cfba4991..c3b3260ba 100644 --- a/helper/resource/testing.go +++ b/helper/resource/testing.go @@ -131,6 +131,22 @@ func TestMain(m interface { } } else { exitCode := m.Run() + + tempDir := os.Getenv(plugintest.EnvTfAccTempDir) + if tempDir == "" { + tempDir = os.TempDir() + } + pathParts := []string{ + strings.TrimRight(tempDir, string(os.PathSeparator)), + "plugintest-terraform", + strconv.Itoa(os.Getpid()), + } + tfDir := strings.Join(pathParts, string(os.PathSeparator)) + if err := os.RemoveAll(tfDir); err != nil { + log.Printf("[WARN] Failed to remove temporary directory for Terraform CLI: %s", err) + + } + os.Exit(exitCode) } } @@ -312,6 +328,7 @@ type ErrorCheckFunc func(error) error // Refer to the Env prefixed constants for environment variables that further // control testing functionality. type TestCase struct { + TFExactVersion string // IsUnitTest allows a test to run regardless of the TF_ACC // environment variable. This should be used with care - only for // fast tests on local resources (e.g. remote state with a local @@ -951,7 +968,11 @@ func Test(t testing.T, c TestCase) { if err != nil { t.Fatalf("Error getting working dir: %s", err) } - helper := plugintest.AutoInitProviderHelper(ctx, sourceDir) + exactVersion := os.Getenv(plugintest.EnvTfAccTerraformVersion) + if len(c.TFExactVersion) > 0 { + exactVersion = c.TFExactVersion + } + helper := plugintest.AutoInitProviderHelperWithExactVersion(ctx, sourceDir, exactVersion) defer func(helper *plugintest.Helper) { err := helper.Close() if err != nil { diff --git a/internal/logging/context.go b/internal/logging/context.go index 0fe8002aa..f7d2a1037 100644 --- a/internal/logging/context.go +++ b/internal/logging/context.go @@ -5,28 +5,14 @@ package logging import ( "context" + "os" + "github.com/hashicorp/go-hclog" "github.com/hashicorp/terraform-plugin-log/tfsdklog" helperlogging "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging" testing "github.com/mitchellh/go-testing-interface" ) -// InitContext creates SDK logger contexts when the provider is running in -// "production" (not under acceptance testing). The incoming context will -// already have the root SDK logger and root provider logger setup from -// terraform-plugin-go tf5server RPC handlers. -func InitContext(ctx context.Context) context.Context { - ctx = tfsdklog.NewSubsystem(ctx, SubsystemHelperSchema, - // All calls are through the HelperSchema* helper functions - tfsdklog.WithAdditionalLocationOffset(1), - tfsdklog.WithLevelFromEnv(EnvTfLogSdkHelperSchema), - // Propagate tf_req_id, tf_rpc, etc. fields - tfsdklog.WithRootFields(), - ) - - return ctx -} - // InitTestContext registers the terraform-plugin-log/tfsdklog test sink, // configures the standard library log package, and creates SDK logger // contexts. The incoming context is expected to be devoid of logging setup. @@ -39,13 +25,23 @@ func InitTestContext(ctx context.Context, t testing.T) context.Context { ctx = tfsdklog.RegisterTestSink(ctx, t) ctx = tfsdklog.NewRootSDKLogger(ctx, tfsdklog.WithLevelFromEnv(EnvTfLogSdk)) + ctx = tfsdklog.NewSubsystem(ctx, SubsystemHelperResource, - // All calls are through the HelperResource* helper functions tfsdklog.WithAdditionalLocationOffset(1), tfsdklog.WithLevelFromEnv(EnvTfLogSdkHelperResource), ) ctx = TestNameContext(ctx, t.Name()) + var logLevelOption = tfsdklog.WithLevel(hclog.Off) + if len(os.Getenv(EnvTfLogInstaller)) > 0 { + logLevelOption = tfsdklog.WithLevelFromEnv(EnvTfLogInstaller) + } + + ctx = tfsdklog.NewSubsystem(ctx, SubsystemInstall, + tfsdklog.WithAdditionalLocationOffset(1), + logLevelOption, + ) + return ctx } diff --git a/internal/logging/context_test.go b/internal/logging/context_test.go index 1d1e85e3d..833b7b544 100644 --- a/internal/logging/context_test.go +++ b/internal/logging/context_test.go @@ -15,43 +15,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/internal/logging" ) -func TestInitContext(t *testing.T) { - t.Parallel() - - var output bytes.Buffer - - ctx := tfsdklogtest.RootLogger(context.Background(), &output) - - // Simulate root logger fields that would have been associated by - // terraform-plugin-go prior to the InitContext() call. - ctx = tfsdklog.SetField(ctx, "tf_rpc", "GetProviderSchema") - ctx = tfsdklog.SetField(ctx, "tf_req_id", "123-testing-123") - - ctx = logging.InitContext(ctx) - - logging.HelperSchemaTrace(ctx, "test message") - - entries, err := tfsdklogtest.MultilineJSONDecode(&output) - - if err != nil { - t.Fatalf("unable to read multiple line JSON: %s", err) - } - - expectedEntries := []map[string]interface{}{ - { - "@level": "trace", - "@message": "test message", - "@module": "sdk.helper_schema", - "tf_rpc": "GetProviderSchema", - "tf_req_id": "123-testing-123", - }, - } - - if diff := cmp.Diff(entries, expectedEntries); diff != "" { - t.Errorf("unexpected difference: %s", diff) - } -} - func TestTestNameContext(t *testing.T) { t.Parallel() diff --git a/internal/logging/environment_variables.go b/internal/logging/environment_variables.go index 2ffc73eee..8f76e4608 100644 --- a/internal/logging/environment_variables.go +++ b/internal/logging/environment_variables.go @@ -20,8 +20,5 @@ const ( // unset. EnvTfLogSdkHelperResource = "TF_LOG_SDK_HELPER_RESOURCE" - // EnvTfLogSdkHelperSchema is an environment variable that sets the logging - // level of SDK helper/schema loggers. Infers root SDK logging level, if - // unset. - EnvTfLogSdkHelperSchema = "TF_LOG_SDK_HELPER_SCHEMA" + EnvTfLogInstaller = "TF_LOG_INSTALLER" ) diff --git a/internal/logging/helper_resource.go b/internal/logging/helper_resource.go index 1b1459f24..3c6463d6b 100644 --- a/internal/logging/helper_resource.go +++ b/internal/logging/helper_resource.go @@ -12,6 +12,7 @@ import ( const ( // SubsystemHelperResource is the tfsdklog subsystem name for helper/resource. SubsystemHelperResource = "helper_resource" + SubsystemInstall = "install" ) // HelperResourceTrace emits a helper/resource subsystem log at TRACE level. diff --git a/internal/logging/helper_schema.go b/internal/logging/helper_schema.go deleted file mode 100644 index 0ecf6bf2e..000000000 --- a/internal/logging/helper_schema.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package logging - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-log/tfsdklog" -) - -const ( - // SubsystemHelperSchema is the tfsdklog subsystem name for helper/schema. - SubsystemHelperSchema = "helper_schema" -) - -// HelperSchemaDebug emits a helper/schema subsystem log at DEBUG level. -func HelperSchemaDebug(ctx context.Context, msg string, additionalFields ...map[string]interface{}) { - tfsdklog.SubsystemDebug(ctx, SubsystemHelperSchema, msg, additionalFields...) -} - -// HelperSchemaError emits a helper/schema subsystem log at ERROR level. -func HelperSchemaError(ctx context.Context, msg string, additionalFields ...map[string]interface{}) { - tfsdklog.SubsystemError(ctx, SubsystemHelperSchema, msg, additionalFields...) -} - -// HelperSchemaTrace emits a helper/schema subsystem log at TRACE level. -func HelperSchemaTrace(ctx context.Context, msg string, additionalFields ...map[string]interface{}) { - tfsdklog.SubsystemTrace(ctx, SubsystemHelperSchema, msg, additionalFields...) -} - -// HelperSchemaWarn emits a helper/schema subsystem log at WARN level. -func HelperSchemaWarn(ctx context.Context, msg string, additionalFields ...map[string]interface{}) { - tfsdklog.SubsystemWarn(ctx, SubsystemHelperSchema, msg, additionalFields...) -} diff --git a/internal/logging/helper_schema_test.go b/internal/logging/helper_schema_test.go deleted file mode 100644 index fea9fc7e3..000000000 --- a/internal/logging/helper_schema_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package logging_test - -import ( - "bytes" - "context" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-log/tfsdklogtest" - - "github.com/hashicorp/terraform-plugin-testing/internal/logging" -) - -func TestHelperSchemaDebug(t *testing.T) { - t.Parallel() - - var output bytes.Buffer - - ctx := tfsdklogtest.RootLogger(context.Background(), &output) - ctx = logging.InitContext(ctx) - - logging.HelperSchemaDebug(ctx, "test message") - - entries, err := tfsdklogtest.MultilineJSONDecode(&output) - - if err != nil { - t.Fatalf("unable to read multiple line JSON: %s", err) - } - - expectedEntries := []map[string]interface{}{ - { - "@level": "debug", - "@message": "test message", - "@module": "sdk.helper_schema", - }, - } - - if diff := cmp.Diff(entries, expectedEntries); diff != "" { - t.Errorf("unexpected difference: %s", diff) - } -} - -func TestHelperSchemaError(t *testing.T) { - t.Parallel() - - var output bytes.Buffer - - ctx := tfsdklogtest.RootLogger(context.Background(), &output) - ctx = logging.InitContext(ctx) - - logging.HelperSchemaError(ctx, "test message") - - entries, err := tfsdklogtest.MultilineJSONDecode(&output) - - if err != nil { - t.Fatalf("unable to read multiple line JSON: %s", err) - } - - expectedEntries := []map[string]interface{}{ - { - "@level": "error", - "@message": "test message", - "@module": "sdk.helper_schema", - }, - } - - if diff := cmp.Diff(entries, expectedEntries); diff != "" { - t.Errorf("unexpected difference: %s", diff) - } -} - -func TestHelperSchemaTrace(t *testing.T) { - t.Parallel() - - var output bytes.Buffer - - ctx := tfsdklogtest.RootLogger(context.Background(), &output) - ctx = logging.InitContext(ctx) - - logging.HelperSchemaTrace(ctx, "test message") - - entries, err := tfsdklogtest.MultilineJSONDecode(&output) - - if err != nil { - t.Fatalf("unable to read multiple line JSON: %s", err) - } - - expectedEntries := []map[string]interface{}{ - { - "@level": "trace", - "@message": "test message", - "@module": "sdk.helper_schema", - }, - } - - if diff := cmp.Diff(entries, expectedEntries); diff != "" { - t.Errorf("unexpected difference: %s", diff) - } -} - -func TestHelperSchemaWarn(t *testing.T) { - t.Parallel() - - var output bytes.Buffer - - ctx := tfsdklogtest.RootLogger(context.Background(), &output) - ctx = logging.InitContext(ctx) - - logging.HelperSchemaWarn(ctx, "test message") - - entries, err := tfsdklogtest.MultilineJSONDecode(&output) - - if err != nil { - t.Fatalf("unable to read multiple line JSON: %s", err) - } - - expectedEntries := []map[string]interface{}{ - { - "@level": "warn", - "@message": "test message", - "@module": "sdk.helper_schema", - }, - } - - if diff := cmp.Diff(entries, expectedEntries); diff != "" { - t.Errorf("unexpected difference: %s", diff) - } -} diff --git a/internal/plugintest/config.go b/internal/plugintest/config.go index b63a55e4e..16e06d674 100644 --- a/internal/plugintest/config.go +++ b/internal/plugintest/config.go @@ -7,8 +7,11 @@ import ( "context" "fmt" "os" + "strconv" "strings" + "sync" + "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-version" install "github.com/hashicorp/hc-install" "github.com/hashicorp/hc-install/checkpoint" @@ -16,6 +19,7 @@ import ( "github.com/hashicorp/hc-install/product" "github.com/hashicorp/hc-install/releases" "github.com/hashicorp/hc-install/src" + "github.com/hashicorp/terraform-plugin-log/tfsdklog" "github.com/hashicorp/terraform-plugin-testing/internal/logging" ) @@ -31,10 +35,21 @@ type Config struct { PreviousPluginExec string } +var versionLocks map[string]*sync.Mutex +var versionLocksMutex sync.Mutex + +func init() { + versionLocks = make(map[string]*sync.Mutex) +} + // DiscoverConfig uses environment variables and other means to automatically // discover a reasonable test helper configuration. func DiscoverConfig(ctx context.Context, sourceDir string) (*Config, error) { tfVersion := strings.TrimPrefix(os.Getenv(EnvTfAccTerraformVersion), "v") + return DiscoverConfigWithExactVersion(ctx, sourceDir, tfVersion) +} + +func DiscoverConfigWithExactVersion(ctx context.Context, sourceDir string, exactVersion string) (*Config, error) { tfPath := os.Getenv(EnvTfAccTerraformPath) tempDir := os.Getenv(EnvTfAccTempDir) @@ -43,6 +58,8 @@ func DiscoverConfig(ctx context.Context, sourceDir string) (*Config, error) { return nil, fmt.Errorf("failed to create temp dir: %w", err) } + installLogger := tfsdklog.GetSDKSubsystemLogger(ctx, logging.SubsystemInstall) + var sources []src.Source switch { case tfPath != "": @@ -51,8 +68,9 @@ func DiscoverConfig(ctx context.Context, sourceDir string) (*Config, error) { sources = append(sources, &fs.AnyVersion{ ExactBinPath: tfPath, }) - case tfVersion != "": - tfVersion, err := version.NewVersion(tfVersion) + + case exactVersion != "": + tfVersion, err := version.NewVersion(exactVersion) if err != nil { return nil, fmt.Errorf("invalid Terraform version: %w", err) @@ -60,11 +78,31 @@ func DiscoverConfig(ctx context.Context, sourceDir string) (*Config, error) { logging.HelperResourceTrace(ctx, fmt.Sprintf("Adding potential Terraform CLI source of releases.hashicorp.com exact version %q for installation in: %s", tfVersion, tfDir)) - sources = append(sources, &releases.ExactVersion{ + if tempDir == "" { + tempDir = os.TempDir() + } + pathParts := []string{ + strings.TrimRight(tempDir, string(os.PathSeparator)), + "plugintest-terraform", + strconv.Itoa(os.Getpid()), + tfVersion.String(), + } + tfDir := strings.Join(pathParts, string(os.PathSeparator)) + if err := os.MkdirAll(tfDir, 0o700); err != nil { + return nil, fmt.Errorf("failed to create temporary directory for Terraform CLI: %w", err) + } + findSource := &fs.ExactVersion{ + ExtraPaths: []string{tfDir}, + Product: product.Terraform, + Version: tfVersion, + } + releasesSource := &releases.ExactVersion{ InstallDir: tfDir, Product: product.Terraform, Version: tfVersion, - }) + } + sources = append(sources, findSource, releasesSource) + default: logging.HelperResourceTrace(ctx, "Adding potential Terraform CLI source of local filesystem PATH lookup") logging.HelperResourceTrace(ctx, fmt.Sprintf("Adding potential Terraform CLI source of checkpoint.hashicorp.com latest version for installation in: %s", tfDir)) @@ -78,11 +116,34 @@ func DiscoverConfig(ctx context.Context, sourceDir string) (*Config, error) { }) } + stdlibLogger := installLogger.StandardLogger(&hclog.StandardLoggerOptions{ + InferLevels: true, + }) + installer := install.NewInstaller() + installer.SetLogger(stdlibLogger) + + var installerMutex *sync.Mutex + if len(exactVersion) > 0 { + normalizedTFVersion := version.Must(version.NewVersion(exactVersion)).String() + versionLocksMutex.Lock() + if _, ok := versionLocks[normalizedTFVersion]; !ok { + versionLocks[normalizedTFVersion] = &sync.Mutex{} + } + installerMutex = versionLocks[normalizedTFVersion] + versionLocksMutex.Unlock() + } + + if installerMutex != nil { + installerMutex.Lock() + } tfExec, err := installer.Ensure(context.Background(), sources) if err != nil { return nil, fmt.Errorf("failed to find or install Terraform CLI from %+v: %w", sources, err) } + if installerMutex != nil { + installerMutex.Unlock() + } ctx = logging.TestTerraformPathContext(ctx, tfExec) @@ -94,3 +155,67 @@ func DiscoverConfig(ctx context.Context, sourceDir string) (*Config, error) { execTempDir: tfDir, }, nil } + +func TFExactVersion(ctx context.Context, v string) error { + tfVersion, err := version.NewVersion(v) + var sources []src.Source + + if err != nil { + return fmt.Errorf("invalid Terraform version: %w", err) + } + + tempDir := os.TempDir() + pathParts := []string{ + strings.TrimRight(tempDir, string(os.PathSeparator)), + "plugintest-terraform", + strconv.Itoa(os.Getpid()), + tfVersion.String(), + } + tfDir := strings.Join(pathParts, string(os.PathSeparator)) + if err := os.MkdirAll(tfDir, 0o700); err != nil { + return fmt.Errorf("failed to create temporary directory for Terraform CLI: %w", err) + } + + logging.HelperResourceTrace(ctx, fmt.Sprintf("Adding potential Terraform CLI source of releases.hashicorp.com exact version %q for installation in: %s", tfVersion, tfDir)) + + findSource := &fs.ExactVersion{ + ExtraPaths: []string{tfDir}, + Product: product.Terraform, + Version: tfVersion, + } + releasesSource := &releases.ExactVersion{ + InstallDir: tfDir, + Product: product.Terraform, + Version: tfVersion, + } + sources = append(sources, findSource, releasesSource) + + installLogger := tfsdklog.GetSDKSubsystemLogger(ctx, logging.SubsystemInstall) + stdlibLogger := installLogger.StandardLogger(&hclog.StandardLoggerOptions{ + InferLevels: true, + }) + + installer := install.NewInstaller() + installer.SetLogger(stdlibLogger) + + var installerMutex *sync.Mutex + normalizedTFVersion := tfVersion.String() + versionLocksMutex.Lock() + if _, ok := versionLocks[normalizedTFVersion]; !ok { + versionLocks[normalizedTFVersion] = &sync.Mutex{} + } + installerMutex = versionLocks[normalizedTFVersion] + versionLocksMutex.Unlock() + + installerMutex.Lock() + tfExec, err := installer.Ensure(context.Background(), sources) + if err != nil { + return fmt.Errorf("failed to find or install Terraform CLI from %+v: %w", sources, err) + } + installerMutex.Unlock() + + ctx = logging.TestTerraformPathContext(ctx, tfExec) + + logging.HelperResourceDebug(ctx, "Found Terraform CLI") + return nil +} diff --git a/internal/plugintest/helper.go b/internal/plugintest/helper.go index 3c9772cfc..5be217377 100644 --- a/internal/plugintest/helper.go +++ b/internal/plugintest/helper.go @@ -34,6 +34,24 @@ func AutoInitProviderHelper(ctx context.Context, sourceDir string) *Helper { return helper } +func AutoInitProviderHelperWithExactVersion(ctx context.Context, sourceDir string, version string) *Helper { + helper, err := AutoInitHelperWithExactVersion(ctx, sourceDir, version) + if err != nil { + fmt.Fprintf(os.Stderr, "cannot run Terraform provider tests: %s\n", err) + os.Exit(1) + } + return helper +} + +func AutoInitHelperWithExactVersion(ctx context.Context, sourceDir string, version string) (*Helper, error) { + config, err := DiscoverConfigWithExactVersion(ctx, sourceDir, version) + if err != nil { + return nil, err + } + + return InitHelper(ctx, config) +} + // Helper is intended as a per-package singleton created in TestMain which // other tests in a package can use to create Terraform execution contexts type Helper struct { @@ -110,14 +128,17 @@ func (h *Helper) Close() error { return nil } + return os.RemoveAll(h.baseDir) +} + +func (h *Helper) CloseExecDir() error { if h.execTempDir != "" { err := os.RemoveAll(h.execTempDir) if err != nil { return err } } - - return os.RemoveAll(h.baseDir) + return nil } // NewWorkingDir creates a new working directory for use in the implementation diff --git a/tfversion/all_test.go b/tfversion/all_test.go index aa326d6bf..7f7f65617 100644 --- a/tfversion/all_test.go +++ b/tfversion/all_test.go @@ -18,10 +18,10 @@ import ( ) func Test_All_RunTest(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.1.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -46,10 +46,10 @@ func Test_All_RunTest(t *testing.T) { //nolint:paralleltest } func Test_All_SkipTest(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.0.7") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.0.7", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -77,11 +77,11 @@ func Test_All_SkipTest(t *testing.T) { //nolint:paralleltest } func Test_All_Error(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.0.7", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil diff --git a/tfversion/any_test.go b/tfversion/any_test.go index 76eacaa01..84ac8c58a 100644 --- a/tfversion/any_test.go +++ b/tfversion/any_test.go @@ -18,10 +18,10 @@ import ( ) func Test_Any_RunTest(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.1.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -43,10 +43,10 @@ func Test_Any_RunTest(t *testing.T) { //nolint:paralleltest } func Test_Any_SkipTest(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.1.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -70,11 +70,11 @@ func Test_Any_SkipTest(t *testing.T) { //nolint:paralleltest } func Test_Any_Error(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.1.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil diff --git a/tfversion/require_above_test.go b/tfversion/require_above_test.go index 8e8c3ea8e..411ee6ae6 100644 --- a/tfversion/require_above_test.go +++ b/tfversion/require_above_test.go @@ -19,10 +19,10 @@ import ( ) func Test_RequireAbove_Equal(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.1.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -42,10 +42,10 @@ func Test_RequireAbove_Equal(t *testing.T) { //nolint:paralleltest } func Test_RequireAbove_Higher(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.1") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.1.1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -65,11 +65,11 @@ func Test_RequireAbove_Higher(t *testing.T) { //nolint:paralleltest } func Test_RequireAbove_Lower(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.0.7") + t.Parallel() plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.0.7", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -88,8 +88,7 @@ func Test_RequireAbove_Lower(t *testing.T) { //nolint:paralleltest } func Test_RequireAbove_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core version. This enables developers @@ -98,6 +97,7 @@ func Test_RequireAbove_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:para // // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -113,10 +113,10 @@ func Test_RequireAbove_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:para } func Test_RequireAbove_Prerelease_EqualPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -132,8 +132,7 @@ func Test_RequireAbove_Prerelease_EqualPrerelease(t *testing.T) { //nolint:paral } func Test_RequireAbove_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not @@ -141,6 +140,7 @@ func Test_RequireAbove_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:par // the core version of the check. plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -157,13 +157,13 @@ func Test_RequireAbove_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:par } func Test_RequireAbove_Prerelease_HigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -180,12 +180,12 @@ func Test_RequireAbove_Prerelease_HigherPrerelease(t *testing.T) { //nolint:para } func Test_RequireAbove_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -201,12 +201,12 @@ func Test_RequireAbove_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:para } func Test_RequireAbove_Prerelease_LowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, diff --git a/tfversion/require_below_test.go b/tfversion/require_below_test.go index 01d09d6b8..8a4d3ec4a 100644 --- a/tfversion/require_below_test.go +++ b/tfversion/require_below_test.go @@ -19,11 +19,11 @@ import ( ) func Test_RequireBelow_Equal(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0") + t.Parallel() plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.7.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -40,10 +40,10 @@ func Test_RequireBelow_Equal(t *testing.T) { //nolint:paralleltest } func Test_RequireBelow_Lower(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.2.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.2.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -66,11 +66,11 @@ func Test_RequireBelow_Lower(t *testing.T) { //nolint:paralleltest } func Test_RequireBelow_Higher(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.4.0") + t.Parallel() plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.4.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -89,8 +89,7 @@ func Test_RequireBelow_Higher(t *testing.T) { //nolint:paralleltest } func Test_RequireBelow_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core version. This enables developers @@ -100,6 +99,7 @@ func Test_RequireBelow_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:para // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -116,14 +116,14 @@ func Test_RequireBelow_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:para } func Test_RequireBelow_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not // ignore the core version of the prerelease version when compared against // the core version of the check. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -139,12 +139,12 @@ func Test_RequireBelow_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:par } func Test_RequireBelow_Prerelease_HigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -160,13 +160,13 @@ func Test_RequireBelow_Prerelease_HigherPrerelease(t *testing.T) { //nolint:para } func Test_RequireBelow_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -183,13 +183,13 @@ func Test_RequireBelow_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:para } func Test_RequireBelow_Prerelease_LowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, diff --git a/tfversion/require_between_test.go b/tfversion/require_between_test.go index 9508ec2a3..fa3c05edc 100644 --- a/tfversion/require_between_test.go +++ b/tfversion/require_between_test.go @@ -19,10 +19,10 @@ import ( ) func Test_RequireBetween(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.2.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.2.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -57,11 +57,11 @@ func Test_RequireBetween(t *testing.T) { //nolint:paralleltest } func Test_RequireBetween_Error_BelowMin(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.1.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -80,7 +80,7 @@ func Test_RequireBetween_Error_BelowMin(t *testing.T) { //nolint:paralleltest } func Test_RequireBetween_Error_EqToMax(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.3.0") + t.Parallel() plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ @@ -102,8 +102,7 @@ func Test_RequireBetween_Error_EqToMax(t *testing.T) { //nolint:paralleltest } func Test_RequireBetween_Prerelease_MaxEqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core version. This enables developers @@ -113,6 +112,7 @@ func Test_RequireBetween_Prerelease_MaxEqualCoreVersion(t *testing.T) { //nolint // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -129,8 +129,7 @@ func Test_RequireBetween_Prerelease_MaxEqualCoreVersion(t *testing.T) { //nolint } func Test_RequireBetween_Prerelease_MinEqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core version. This enables developers @@ -139,6 +138,7 @@ func Test_RequireBetween_Prerelease_MinEqualCoreVersion(t *testing.T) { //nolint // // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -154,14 +154,14 @@ func Test_RequireBetween_Prerelease_MinEqualCoreVersion(t *testing.T) { //nolint } func Test_RequireBetween_Prerelease_MaxHigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not // ignore the core version of the prerelease version when compared against // the core version of the check. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -177,8 +177,7 @@ func Test_RequireBetween_Prerelease_MaxHigherCoreVersion(t *testing.T) { //nolin } func Test_RequireBetween_Prerelease_MinHigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not @@ -186,6 +185,7 @@ func Test_RequireBetween_Prerelease_MinHigherCoreVersion(t *testing.T) { //nolin // the core version of the check. plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -202,12 +202,12 @@ func Test_RequireBetween_Prerelease_MinHigherCoreVersion(t *testing.T) { //nolin } func Test_RequireBetween_Prerelease_MaxHigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -223,13 +223,13 @@ func Test_RequireBetween_Prerelease_MaxHigherPrerelease(t *testing.T) { //nolint } func Test_RequireBetween_Prerelease_MinHigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -246,13 +246,13 @@ func Test_RequireBetween_Prerelease_MinHigherPrerelease(t *testing.T) { //nolint } func Test_RequireBetween_Prerelease_MaxLowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -269,12 +269,12 @@ func Test_RequireBetween_Prerelease_MaxLowerCoreVersion(t *testing.T) { //nolint } func Test_RequireBetween_Prerelease_MinLowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -290,13 +290,13 @@ func Test_RequireBetween_Prerelease_MinLowerCoreVersion(t *testing.T) { //nolint } func Test_RequireBetween_Prerelease_MaxLowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -313,12 +313,12 @@ func Test_RequireBetween_Prerelease_MaxLowerPrerelease(t *testing.T) { //nolint: } func Test_RequireBetween_Prerelease_MinLowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, diff --git a/tfversion/require_not_test.go b/tfversion/require_not_test.go index 6eba3e7ba..0b6334ec6 100644 --- a/tfversion/require_not_test.go +++ b/tfversion/require_not_test.go @@ -19,10 +19,10 @@ import ( ) func Test_RequireNot(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.4.3") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.4.3", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -38,11 +38,11 @@ func Test_RequireNot(t *testing.T) { //nolint:paralleltest } func Test_RequireNot_Error(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.1.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -61,8 +61,7 @@ func Test_RequireNot_Error(t *testing.T) { //nolint:paralleltest } func Test_RequireNot_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core version. This enables developers @@ -72,6 +71,7 @@ func Test_RequireNot_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:parall // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 plugintest.TestExpectTFatal(t, func() { r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -88,14 +88,14 @@ func Test_RequireNot_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:parall } func Test_RequireNot_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not // ignore the core version of the prerelease version when compared against // the core version of the check. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -111,12 +111,12 @@ func Test_RequireNot_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:paral } func Test_RequireNot_Prerelease_HigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -132,12 +132,12 @@ func Test_RequireNot_Prerelease_HigherPrerelease(t *testing.T) { //nolint:parall } func Test_RequireNot_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -153,12 +153,12 @@ func Test_RequireNot_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:parall } func Test_RequireNot_Prerelease_LowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, diff --git a/tfversion/skip_above_test.go b/tfversion/skip_above_test.go index db9898c37..388314b26 100644 --- a/tfversion/skip_above_test.go +++ b/tfversion/skip_above_test.go @@ -16,10 +16,10 @@ import ( ) func Test_SkipAbove_Lower(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.3.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.3.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -42,10 +42,10 @@ func Test_SkipAbove_Lower(t *testing.T) { //nolint:paralleltest } func Test_SkipAbove_Equal(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.2.9") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.2.9", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -68,10 +68,10 @@ func Test_SkipAbove_Equal(t *testing.T) { //nolint:paralleltest } func Test_SkipAbove_Higher(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.1") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -87,8 +87,7 @@ func Test_SkipAbove_Higher(t *testing.T) { //nolint:paralleltest } func Test_SkipAbove_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core version. This enables developers @@ -97,6 +96,7 @@ func Test_SkipAbove_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralle // // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -112,10 +112,10 @@ func Test_SkipAbove_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralle } func Test_SkipAbove_Prerelease_EqualPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -131,14 +131,14 @@ func Test_SkipAbove_Prerelease_EqualPrerelease(t *testing.T) { //nolint:parallel } func Test_SkipAbove_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not // ignore the core version of the prerelease version when compared against // the core version of the check. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -154,12 +154,12 @@ func Test_SkipAbove_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:parall } func Test_SkipAbove_Prerelease_HigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -175,12 +175,12 @@ func Test_SkipAbove_Prerelease_HigherPrerelease(t *testing.T) { //nolint:paralle } func Test_SkipAbove_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -196,12 +196,12 @@ func Test_SkipAbove_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:paralle } func Test_SkipAbove_Prerelease_LowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, diff --git a/tfversion/skip_below_test.go b/tfversion/skip_below_test.go index 4999a2dea..a442ecf2f 100644 --- a/tfversion/skip_below_test.go +++ b/tfversion/skip_below_test.go @@ -16,10 +16,10 @@ import ( ) func Test_SkipBelow_Lower(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.0.7") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.0.7", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -41,10 +41,10 @@ func Test_SkipBelow_Lower(t *testing.T) { //nolint:paralleltest } func Test_SkipBelow_Equal(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.1.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -64,10 +64,10 @@ func Test_SkipBelow_Equal(t *testing.T) { //nolint:paralleltest } func Test_SkipBelow_Higher(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.1") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.1.1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -87,8 +87,7 @@ func Test_SkipBelow_Higher(t *testing.T) { //nolint:paralleltest } func Test_SkipBelow_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core release. This enables developers @@ -97,6 +96,7 @@ func Test_SkipBelow_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralle // // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -112,10 +112,10 @@ func Test_SkipBelow_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralle } func Test_SkipBelow_Prerelease_EqualPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -131,14 +131,14 @@ func Test_SkipBelow_Prerelease_EqualPrerelease(t *testing.T) { //nolint:parallel } func Test_SkipBelow_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not // ignore the core version of the prerelease version when compared against // the core version of the check. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -154,12 +154,12 @@ func Test_SkipBelow_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:parall } func Test_SkipBelow_Prerelease_HigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -175,12 +175,12 @@ func Test_SkipBelow_Prerelease_HigherPrerelease(t *testing.T) { //nolint:paralle } func Test_SkipBelow_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -196,12 +196,12 @@ func Test_SkipBelow_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:paralle } func Test_SkipBelow_Prerelease_LowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, diff --git a/tfversion/skip_between_test.go b/tfversion/skip_between_test.go index 35ced5279..5972679fd 100644 --- a/tfversion/skip_between_test.go +++ b/tfversion/skip_between_test.go @@ -18,10 +18,10 @@ import ( ) func Test_SkipBetween_SkipTest(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.2.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.2.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -56,10 +56,10 @@ func Test_SkipBetween_SkipTest(t *testing.T) { //nolint:paralleltest } func Test_SkipBetween_RunTest_AboveMax(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.3.0") + t.Parallel() r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.3.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -75,10 +75,10 @@ func Test_SkipBetween_RunTest_AboveMax(t *testing.T) { //nolint:paralleltest } func Test_SkipBetween_RunTest_EqToMin(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.2.0") + t.Parallel() r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.2.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -94,8 +94,7 @@ func Test_SkipBetween_RunTest_EqToMin(t *testing.T) { //nolint:paralleltest } func Test_SkipBetween_Prerelease_MaxEqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core version. This enables developers @@ -104,6 +103,7 @@ func Test_SkipBetween_Prerelease_MaxEqualCoreVersion(t *testing.T) { //nolint:pa // // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -119,8 +119,7 @@ func Test_SkipBetween_Prerelease_MaxEqualCoreVersion(t *testing.T) { //nolint:pa } func Test_SkipBetween_Prerelease_MinEqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core version. This enables developers @@ -129,6 +128,7 @@ func Test_SkipBetween_Prerelease_MinEqualCoreVersion(t *testing.T) { //nolint:pa // // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -144,14 +144,14 @@ func Test_SkipBetween_Prerelease_MinEqualCoreVersion(t *testing.T) { //nolint:pa } func Test_SkipBetween_Prerelease_MaxHigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not // ignore the core version of the prerelease version when compared against // the core version of the check. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -167,14 +167,14 @@ func Test_SkipBetween_Prerelease_MaxHigherCoreVersion(t *testing.T) { //nolint:p } func Test_SkipBetween_Prerelease_MinHigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not // ignore the core version of the prerelease version when compared against // the core version of the check. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -190,12 +190,12 @@ func Test_SkipBetween_Prerelease_MinHigherCoreVersion(t *testing.T) { //nolint:p } func Test_SkipBetween_Prerelease_MaxHigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -211,12 +211,12 @@ func Test_SkipBetween_Prerelease_MaxHigherPrerelease(t *testing.T) { //nolint:pa } func Test_SkipBetween_Prerelease_MinHigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -232,12 +232,12 @@ func Test_SkipBetween_Prerelease_MinHigherPrerelease(t *testing.T) { //nolint:pa } func Test_SkipBetween_Prerelease_MaxLowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -253,12 +253,12 @@ func Test_SkipBetween_Prerelease_MaxLowerCoreVersion(t *testing.T) { //nolint:pa } func Test_SkipBetween_Prerelease_MinLowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -274,12 +274,12 @@ func Test_SkipBetween_Prerelease_MinLowerCoreVersion(t *testing.T) { //nolint:pa } func Test_SkipBetween_Prerelease_MaxLowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -295,12 +295,12 @@ func Test_SkipBetween_Prerelease_MaxLowerPrerelease(t *testing.T) { //nolint:par } func Test_SkipBetween_Prerelease_MinLowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, diff --git a/tfversion/skip_if_not_alpha_test.go b/tfversion/skip_if_not_alpha_test.go index f778968a9..1a11d785e 100644 --- a/tfversion/skip_if_not_alpha_test.go +++ b/tfversion/skip_if_not_alpha_test.go @@ -17,10 +17,10 @@ import ( ) func Test_SkipIfNotAlpha_SkipTest_Stable(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -38,10 +38,10 @@ func Test_SkipIfNotAlpha_SkipTest_Stable(t *testing.T) { //nolint:paralleltest } func Test_SkipIfNotAlpha_SkipTest_Beta1(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-beta1") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-beta1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -56,10 +56,10 @@ func Test_SkipIfNotAlpha_SkipTest_Beta1(t *testing.T) { //nolint:paralleltest }) } func Test_SkipIfNotAlpha_SkipTest_RC(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc2") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc2", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -75,10 +75,10 @@ func Test_SkipIfNotAlpha_SkipTest_RC(t *testing.T) { //nolint:paralleltest } func Test_SkipIfNotAlpha_RunTest_Alpha(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.9.0-alpha20240501") + t.Parallel() r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.9.0-alpha20240501", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, diff --git a/tfversion/skip_if_not_prerelease_test.go b/tfversion/skip_if_not_prerelease_test.go index 545017ed0..3f77a05eb 100644 --- a/tfversion/skip_if_not_prerelease_test.go +++ b/tfversion/skip_if_not_prerelease_test.go @@ -17,10 +17,10 @@ import ( ) func Test_SkipIfNotPrerelease_SkipTest_Stable(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -38,10 +38,10 @@ func Test_SkipIfNotPrerelease_SkipTest_Stable(t *testing.T) { //nolint:parallelt } func Test_SkipIfNotPrerelease_RunTest_Alpha(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.9.0-alpha20240501") + t.Parallel() r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.9.0-alpha20240501", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -57,10 +57,10 @@ func Test_SkipIfNotPrerelease_RunTest_Alpha(t *testing.T) { //nolint:paralleltes } func Test_SkipIfNotPrerelease_RunTest_Beta1(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-beta1") + t.Parallel() r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.8.0-beta1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -75,10 +75,10 @@ func Test_SkipIfNotPrerelease_RunTest_Beta1(t *testing.T) { //nolint:paralleltes }) } func Test_SkipIfNotPrerelease_RunTest_RC(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc2") + t.Parallel() r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.8.0-rc2", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, diff --git a/tfversion/skip_if_test.go b/tfversion/skip_if_test.go index 5b645b954..331220885 100644 --- a/tfversion/skip_if_test.go +++ b/tfversion/skip_if_test.go @@ -18,10 +18,10 @@ import ( ) func Test_SkipIf_SkipTest(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.4.3") + t.Parallel() r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.4.3", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature return nil, nil @@ -39,10 +39,10 @@ func Test_SkipIf_SkipTest(t *testing.T) { //nolint:paralleltest } func Test_SkipIf_RunTest(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0") + t.Parallel() r.UnitTest(&testinginterface.RuntimeT{}, r.TestCase{ + TFExactVersion: "1.1.0", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -58,8 +58,7 @@ func Test_SkipIf_RunTest(t *testing.T) { //nolint:paralleltest } func Test_SkipIf_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // Pragmatic compromise that 1.8.0-rc1 prerelease is considered to // be equivalent to the 1.8.0 core version. This enables developers @@ -68,6 +67,7 @@ func Test_SkipIf_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:parallelte // // Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303 r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -83,14 +83,14 @@ func Test_SkipIf_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:parallelte } func Test_SkipIf_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be below the // 1.8.0 core version. This intentionally verifies that the logic does not // ignore the core version of the prerelease version when compared against // the core version of the check. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -106,12 +106,12 @@ func Test_SkipIf_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:parallelt } func Test_SkipIf_Prerelease_HigherPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.7.0-rc1") + t.Parallel() // The 1.7.0-rc1 prerelease should always be considered to be // below the 1.7.0-rc2 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.7.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -127,12 +127,12 @@ func Test_SkipIf_Prerelease_HigherPrerelease(t *testing.T) { //nolint:parallelte } func Test_SkipIf_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.7.0 core version. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), }, @@ -148,12 +148,12 @@ func Test_SkipIf_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:parallelte } func Test_SkipIf_Prerelease_LowerPrerelease(t *testing.T) { //nolint:paralleltest - t.Setenv("TF_ACC_TERRAFORM_PATH", "") - t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1") + t.Parallel() // The 1.8.0-rc1 prerelease should always be considered to be // above the 1.8.0-beta1 prerelease. r.UnitTest(t, r.TestCase{ + TFExactVersion: "1.8.0-rc1", ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(testprovider.Provider{}), },