diff --git a/helper/resource/testing_new.go b/helper/resource/testing_new.go index a05cf68b1..cb1bca2b4 100644 --- a/helper/resource/testing_new.go +++ b/helper/resource/testing_new.go @@ -200,7 +200,7 @@ func runNewTest(ctx context.Context, t testing.T, c TestCase, helper *plugintest } } - if cfg.HasConfiguration() && !step.Destroy && len(step.Taint) > 0 { + if cfg != nil && !step.Destroy && len(step.Taint) > 0 { err := testStepTaint(ctx, step, wd) if err != nil { @@ -229,14 +229,18 @@ func runNewTest(ctx context.Context, t testing.T, c TestCase, helper *plugintest protov6: protov6ProviderFactories(c.ProtoV6ProviderFactories).merge(step.ProtoV6ProviderFactories), } - hasProviderBlock, err := cfg.HasProviderBlock(ctx) + var hasProviderBlock bool - if err != nil { - logging.HelperResourceError(ctx, - "TestStep error determining whether configuration contains provider block", - map[string]interface{}{logging.KeyError: err}, - ) - t.Fatalf("TestStep %d/%d error determining whether configuration contains provider block: %s", stepNumber, len(c.Steps), err) + if cfg != nil { + hasProviderBlock, err = cfg.HasProviderBlock(ctx) + + if err != nil { + logging.HelperResourceError(ctx, + "TestStep error determining whether configuration contains provider block", + map[string]interface{}{logging.KeyError: err}, + ) + t.Fatalf("TestStep %d/%d error determining whether configuration contains provider block: %s", stepNumber, len(c.Steps), err) + } } var testStepConfig teststep.Config @@ -373,7 +377,7 @@ func runNewTest(ctx context.Context, t testing.T, c TestCase, helper *plugintest continue } - if cfg.HasConfiguration() { + if cfg != nil { logging.HelperResourceTrace(ctx, "TestStep is Config mode") err := testStepNewConfig(ctx, t, c, wd, step, providers, stepIndex) @@ -410,24 +414,29 @@ func runNewTest(ctx context.Context, t testing.T, c TestCase, helper *plugintest } } - hasTerraformBlock, err := cfg.HasTerraformBlock(ctx) + var hasTerraformBlock bool + var hasProviderBlock bool - if err != nil { - logging.HelperResourceError(ctx, - "Error determining whether configuration contains terraform block", - map[string]interface{}{logging.KeyError: err}, - ) - t.Fatalf("Error determining whether configuration contains terraform block: %s", err) - } + if cfg != nil { + hasTerraformBlock, err = cfg.HasTerraformBlock(ctx) + + if err != nil { + logging.HelperResourceError(ctx, + "Error determining whether configuration contains terraform block", + map[string]interface{}{logging.KeyError: err}, + ) + t.Fatalf("Error determining whether configuration contains terraform block: %s", err) + } - hasProviderBlock, err := cfg.HasProviderBlock(ctx) + hasProviderBlock, err = cfg.HasProviderBlock(ctx) - if err != nil { - logging.HelperResourceError(ctx, - "Error determining whether configuration contains provider block", - map[string]interface{}{logging.KeyError: err}, - ) - t.Fatalf("Error determining whether configuration contains provider block: %s", err) + if err != nil { + logging.HelperResourceError(ctx, + "Error determining whether configuration contains provider block", + map[string]interface{}{logging.KeyError: err}, + ) + t.Fatalf("Error determining whether configuration contains provider block: %s", err) + } } mergedConfig := step.mergedConfig(ctx, c, hasTerraformBlock, hasProviderBlock) @@ -527,14 +536,18 @@ func testIDRefresh(ctx context.Context, t testing.T, c TestCase, wd *plugintest. t.Fatalf("Error creating provider configuration for import test config: %s", err) } - hasProviderBlock, err := cfg.HasProviderBlock(ctx) + var hasProviderBlock bool - if err != nil { - logging.HelperResourceError(ctx, - "Error determining whether configuration contains provider block for import test config", - map[string]interface{}{logging.KeyError: err}, - ) - t.Fatalf("Error determining whether configuration contains provider block for import test config: %s", err) + if cfg != nil { + hasProviderBlock, err = cfg.HasProviderBlock(ctx) + + if err != nil { + logging.HelperResourceError(ctx, + "Error determining whether configuration contains provider block for import test config", + map[string]interface{}{logging.KeyError: err}, + ) + t.Fatalf("Error determining whether configuration contains provider block for import test config: %s", err) + } } // Return value from c.ProviderConfig() is assigned to Raw as this was previously being diff --git a/helper/resource/testing_new_config.go b/helper/resource/testing_new_config.go index 3d47ad54a..e47bb3820 100644 --- a/helper/resource/testing_new_config.go +++ b/helper/resource/testing_new_config.go @@ -40,24 +40,29 @@ func testStepNewConfig(ctx context.Context, t testing.T, c TestCase, wd *plugint return fmt.Errorf("Error creating config: %w", err) } - hasTerraformBlock, err := cfg.HasTerraformBlock(ctx) + var hasTerraformBlock bool + var hasProviderBlock bool - if err != nil { - logging.HelperResourceError(ctx, - "Error determining whether configuration contains terraform block", - map[string]interface{}{logging.KeyError: err}, - ) - t.Fatalf("Error determining whether configuration contains terraform block: %s", err) - } + if cfg != nil { + hasTerraformBlock, err = cfg.HasTerraformBlock(ctx) + + if err != nil { + logging.HelperResourceError(ctx, + "Error determining whether configuration contains terraform block", + map[string]interface{}{logging.KeyError: err}, + ) + t.Fatalf("Error determining whether configuration contains terraform block: %s", err) + } - hasProviderBlock, err := cfg.HasProviderBlock(ctx) + hasProviderBlock, err = cfg.HasProviderBlock(ctx) - if err != nil { - logging.HelperResourceError(ctx, - "Error determining whether configuration contains provider block", - map[string]interface{}{logging.KeyError: err}, - ) - t.Fatalf("Error determining whether configuration contains provider block: %s", err) + if err != nil { + logging.HelperResourceError(ctx, + "Error determining whether configuration contains provider block", + map[string]interface{}{logging.KeyError: err}, + ) + t.Fatalf("Error determining whether configuration contains provider block: %s", err) + } } mergedConfig := step.mergedConfig(ctx, c, hasTerraformBlock, hasProviderBlock) diff --git a/helper/resource/testing_new_import_state.go b/helper/resource/testing_new_import_state.go index cd6cb03ee..89c56feba 100644 --- a/helper/resource/testing_new_import_state.go +++ b/helper/resource/testing_new_import_state.go @@ -23,8 +23,6 @@ import ( func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest.Helper, wd *plugintest.WorkingDir, step TestStep, cfg teststep.Config, providers *providerFactories, stepIndex int) error { t.Helper() - var testStepConfig teststep.Config - testStepConfig, err := teststep.Configuration( teststep.ConfigurationRequest{ Directory: teststep.Pointer( @@ -100,11 +98,11 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest logging.HelperResourceTrace(ctx, fmt.Sprintf("Using import identifier: %s", importId)) // Create working directory for import tests - if !testStepConfig.HasConfiguration() { + if testStepConfig == nil { logging.HelperResourceTrace(ctx, "Using prior TestStep Config for import") testStepConfig = cfg - if !testStepConfig.HasConfiguration() { + if testStepConfig == nil { t.Fatal("Cannot import state with no specified config") } } diff --git a/helper/resource/teststep_validate.go b/helper/resource/teststep_validate.go index 74d9ab3b3..d03c634d6 100644 --- a/helper/resource/teststep_validate.go +++ b/helper/resource/teststep_validate.go @@ -79,10 +79,14 @@ func (s TestStep) hasProviders(ctx context.Context, stepIndex int, testName stri return false, err } - cfgHasProviders, err := cfg.HasProviderBlock(ctx) + var cfgHasProviders bool - if err != nil { - return false, err + if cfg != nil { + cfgHasProviders, err = cfg.HasProviderBlock(ctx) + + if err != nil { + return false, err + } } if cfgHasProviders { @@ -115,13 +119,13 @@ func (s TestStep) validate(ctx context.Context, req testStepValidateRequest) err logging.HelperResourceTrace(ctx, "Validating TestStep") - if !req.StepConfiguration.HasConfiguration() && !s.ImportState && !s.RefreshState { + if req.StepConfiguration == nil && !s.ImportState && !s.RefreshState { err := fmt.Errorf("TestStep missing Config or ConfigDirectory or ImportState or RefreshState") logging.HelperResourceError(ctx, "TestStep validation error", map[string]interface{}{logging.KeyError: err}) return err } - if req.StepConfiguration.HasConfiguration() && s.RefreshState { + if req.StepConfiguration != nil && s.RefreshState { err := fmt.Errorf("TestStep cannot have Config and RefreshState") logging.HelperResourceError(ctx, "TestStep validation error", map[string]interface{}{logging.KeyError: err}) return err @@ -153,13 +157,13 @@ func (s TestStep) validate(ctx context.Context, req testStepValidateRequest) err } } - if req.TestCaseHasExternalProviders && req.StepConfiguration.HasConfigurationFiles() { + if req.TestCaseHasExternalProviders && req.StepConfiguration != nil && req.StepConfiguration.HasConfigurationFiles() { err := fmt.Errorf("Providers must only be specified within the terraform configuration files when using TestStep.ConfigDirectory") logging.HelperResourceError(ctx, "TestStep validation error", map[string]interface{}{logging.KeyError: err}) return err } - if s.hasExternalProviders() && req.StepConfiguration.HasConfigurationFiles() { + if s.hasExternalProviders() && req.StepConfiguration != nil && req.StepConfiguration.HasConfigurationFiles() { err := fmt.Errorf("Providers must only be specified within the terraform configuration files when using TestStep.ConfigDirectory") logging.HelperResourceError(ctx, "TestStep validation error", map[string]interface{}{logging.KeyError: err}) return err @@ -179,11 +183,15 @@ func (s TestStep) validate(ctx context.Context, req testStepValidateRequest) err return err } - cfgHasProviderBlock, err := req.StepConfiguration.HasProviderBlock(ctx) + var cfgHasProviderBlock bool - if err != nil { - logging.HelperResourceError(ctx, "TestStep error checking for if configuration has provider block", map[string]interface{}{logging.KeyError: err}) - return err + if req.StepConfiguration != nil { + cfgHasProviderBlock, err = req.StepConfiguration.HasProviderBlock(ctx) + + if err != nil { + logging.HelperResourceError(ctx, "TestStep error checking for if configuration has provider block", map[string]interface{}{logging.KeyError: err}) + return err + } } if !req.TestCaseHasProviders && !hasProviders && !cfgHasProviderBlock { @@ -201,7 +209,7 @@ func (s TestStep) validate(ctx context.Context, req testStepValidateRequest) err } if len(s.ConfigPlanChecks.PreApply) > 0 { - if !req.StepConfiguration.HasConfiguration() { + if req.StepConfiguration == nil { err := fmt.Errorf("TestStep ConfigPlanChecks.PreApply must only be specified with Config") logging.HelperResourceError(ctx, "TestStep validation error", map[string]interface{}{logging.KeyError: err}) return err @@ -214,13 +222,13 @@ func (s TestStep) validate(ctx context.Context, req testStepValidateRequest) err } } - if len(s.ConfigPlanChecks.PostApplyPreRefresh) > 0 && !req.StepConfiguration.HasConfiguration() { + if len(s.ConfigPlanChecks.PostApplyPreRefresh) > 0 && req.StepConfiguration == nil { err := fmt.Errorf("TestStep ConfigPlanChecks.PostApplyPreRefresh must only be specified with Config") logging.HelperResourceError(ctx, "TestStep validation error", map[string]interface{}{logging.KeyError: err}) return err } - if len(s.ConfigPlanChecks.PostApplyPostRefresh) > 0 && !req.StepConfiguration.HasConfiguration() { + if len(s.ConfigPlanChecks.PostApplyPostRefresh) > 0 && req.StepConfiguration == nil { err := fmt.Errorf("TestStep ConfigPlanChecks.PostApplyPostRefresh must only be specified with Config") logging.HelperResourceError(ctx, "TestStep validation error", map[string]interface{}{logging.KeyError: err}) return err diff --git a/internal/plugintest/working_dir.go b/internal/plugintest/working_dir.go index 59fda2150..a72e0c5a4 100644 --- a/internal/plugintest/working_dir.go +++ b/internal/plugintest/working_dir.go @@ -98,10 +98,12 @@ func (wd *WorkingDir) SetConfig(ctx context.Context, cfg teststep.Config, vars c wd.configFilename = outFilename // Write configuration - err = cfg.Write(ctx, wd.baseDir) + if cfg != nil { + err = cfg.Write(ctx, wd.baseDir) - if err != nil { - return err + if err != nil { + return err + } } //Write configuration variables diff --git a/internal/teststep/config.go b/internal/teststep/config.go index bc5764024..428ded810 100644 --- a/internal/teststep/config.go +++ b/internal/teststep/config.go @@ -5,9 +5,7 @@ package teststep import ( "context" - "encoding/json" "errors" - "fmt" "io" "os" "path/filepath" @@ -25,18 +23,12 @@ var ( ) type Config interface { - HasConfiguration() bool HasConfigurationFiles() bool HasProviderBlock(context.Context) (bool, error) HasTerraformBlock(context.Context) (bool, error) Write(context.Context, string) error } -type configuration struct { - directory string - raw string -} - type ConfigurationRequest struct { Directory *string Raw *string @@ -50,107 +42,20 @@ func (c ConfigurationRequest) Validate() error { return nil } -func Configuration(req ConfigurationRequest) (configuration, error) { - var config configuration - - if req.Directory != nil { - config.directory = *req.Directory - } - - if req.Raw != nil { - config.raw = *req.Raw - } - - return config, nil -} - -func (c configuration) HasConfiguration() bool { - if c.directory != "" { - return true - } - - if c.raw != "" { - return true - } - - return false -} - -func (c configuration) HasConfigurationFiles() bool { - return c.directory != "" -} - -// HasProviderBlock returns true if the Config has declared a provider -// configuration block, e.g. provider "examplecloud" {...} -func (c configuration) HasProviderBlock(ctx context.Context) (bool, error) { - switch { - case c.hasRaw(ctx): - return providerConfigBlockRegex.MatchString(c.raw), nil - case c.hasDirectory(ctx): - pwd, err := os.Getwd() - - if err != nil { - return false, err - } - - configDirectory := filepath.Join(pwd, c.directory) - - contains, err := filesContains(configDirectory, providerConfigBlockRegex) - - if err != nil { - return false, err - } - - return contains, nil - } - - return false, nil -} - -// HasTerraformBlock returns true if the Config has declared a terraform -// configuration block, e.g. terraform {...} -func (c configuration) HasTerraformBlock(ctx context.Context) (bool, error) { - switch { - case c.hasRaw(ctx): - return terraformConfigBlockRegex.MatchString(c.raw), nil - case c.hasDirectory(ctx): - pwd, err := os.Getwd() - - if err != nil { - return false, err - } - - configDirectory := filepath.Join(pwd, c.directory) - - contains, err := filesContains(configDirectory, terraformConfigBlockRegex) - - if err != nil { - return false, err - } - - return contains, nil +func Configuration(req ConfigurationRequest) (Config, error) { + if req.Directory != nil && *req.Directory != "" { + return configurationDirectory{ + directory: *req.Directory, + }, nil } - return false, nil -} - -func (c configuration) Write(ctx context.Context, dest string) error { - switch { - case c.directory != "": - err := c.writeDirectory(ctx, dest) - - if err != nil { - return err - } - case c.raw != "": - err := c.writeRaw(ctx, dest) - - if err != nil { - return err - } + if req.Raw != nil && *req.Raw != "" { + return configurationString{ + raw: *req.Raw, + }, nil } - return nil + return nil, nil } func copyFiles(path string, dstPath string) error { @@ -250,57 +155,6 @@ func fileContains(path string, find *regexp.Regexp) (bool, error) { return find.MatchString(string(f)), nil } -func (c configuration) hasDirectory(_ context.Context) bool { - return c.directory != "" -} - -func (c configuration) hasRaw(_ context.Context) bool { - return c.raw != "" -} - -// writeDirectory copies the contents of c.directory to dest. -func (c configuration) writeDirectory(_ context.Context, dest string) error { - // Copy all files from c.directory to dest - pwd, err := os.Getwd() - - if err != nil { - return err - } - - configDirectory := filepath.Join(pwd, c.directory) - - err = copyFiles(configDirectory, dest) - - if err != nil { - return err - } - - return nil -} - -func (c configuration) writeRaw(_ context.Context, dest string) error { - outFilename := filepath.Join(dest, rawConfigFileName) - rmFilename := filepath.Join(dest, rawConfigFileNameJSON) - - bCfg := []byte(c.raw) - - if json.Valid(bCfg) { - outFilename, rmFilename = rmFilename, outFilename - } - - if err := os.Remove(rmFilename); err != nil && !os.IsNotExist(err) { - return fmt.Errorf("unable to remove %q: %w", rmFilename, err) - } - - err := os.WriteFile(outFilename, bCfg, 0700) - - if err != nil { - return err - } - - return nil -} - func Pointer[T any](in T) *T { return &in } diff --git a/internal/teststep/config_test.go b/internal/teststep/config_test.go index 0789df650..be10983b6 100644 --- a/internal/teststep/config_test.go +++ b/internal/teststep/config_test.go @@ -4,7 +4,6 @@ package teststep import ( - "context" "testing" "github.com/google/go-cmp/cmp" @@ -60,115 +59,3 @@ func TestConfigurationRequest_Validate(t *testing.T) { }) } } - -func TestConfiguration_HasProviderBlock(t *testing.T) { - t.Parallel() - - testCases := map[string]struct { - config configuration - expected bool - }{ - "no-config": { - config: configuration{}, - expected: false, - }, - "provider-meta-attribute": { - config: configuration{ - raw: ` -resource "test_test" "test" { - provider = test.test -} -`, - }, - expected: false, - }, - "provider-object-attribute": { - config: configuration{ - raw: ` -resource "test_test" "test" { - test = { - provider = { - test = true - } - } -} -`, - }, - expected: false, - }, - "provider-string-attribute": { - config: configuration{ - raw: ` -resource "test_test" "test" { - test = { - provider = "test" - } -} -`, - }, - expected: false, - }, - "provider-block-quoted-with-attributes": { - config: configuration{ - raw: ` -provider "test" { - test = true -} - -resource "test_test" "test" {} -`, - }, - expected: true, - }, - "provider-block-unquoted-with-attributes": { - config: configuration{ - raw: ` -provider test { - test = true -} - -resource "test_test" "test" {} -`, - }, - expected: true, - }, - "provider-block-quoted-without-attributes": { - config: configuration{ - raw: ` -provider "test" {} - -resource "test_test" "test" {} -`, - }, - expected: true, - }, - "provider-block-unquoted-without-attributes": { - config: configuration{ - raw: ` -provider test {} - -resource "test_test" "test" {} -`, - }, - expected: true, - }, - } - - for name, testCase := range testCases { - name, testCase := name, testCase - - t.Run(name, func(t *testing.T) { - t.Parallel() - - got, err := testCase.config.HasProviderBlock(context.Background()) - - if err != nil { - t.Errorf("unexpected error: %s", err) - } - - if testCase.expected != got { - t.Errorf("expected %t, got %t", testCase.expected, got) - } - }) - } -} diff --git a/internal/teststep/directory.go b/internal/teststep/directory.go new file mode 100644 index 000000000..e57ca2ea0 --- /dev/null +++ b/internal/teststep/directory.go @@ -0,0 +1,77 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package teststep + +import ( + "context" + "os" + "path/filepath" +) + +type configurationDirectory struct { + directory string +} + +func (c configurationDirectory) HasConfigurationFiles() bool { + return true +} + +// HasProviderBlock returns true if the Config has declared a provider +// configuration block, e.g. provider "examplecloud" {...} +func (c configurationDirectory) HasProviderBlock(ctx context.Context) (bool, error) { + pwd, err := os.Getwd() + + if err != nil { + return false, err + } + + configDirectory := filepath.Join(pwd, c.directory) + + contains, err := filesContains(configDirectory, providerConfigBlockRegex) + + if err != nil { + return false, err + } + + return contains, nil +} + +// HasTerraformBlock returns true if the Config has declared a terraform +// configuration block, e.g. terraform {...} +func (c configurationDirectory) HasTerraformBlock(ctx context.Context) (bool, error) { + pwd, err := os.Getwd() + + if err != nil { + return false, err + } + + configDirectory := filepath.Join(pwd, c.directory) + + contains, err := filesContains(configDirectory, terraformConfigBlockRegex) + + if err != nil { + return false, err + } + + return contains, nil +} + +func (c configurationDirectory) Write(ctx context.Context, dest string) error { + // Copy all files from c.directory to dest + pwd, err := os.Getwd() + + if err != nil { + return err + } + + configDirectory := filepath.Join(pwd, c.directory) + + err = copyFiles(configDirectory, dest) + + if err != nil { + return err + } + + return nil +} diff --git a/internal/teststep/raw.go b/internal/teststep/raw.go new file mode 100644 index 000000000..9a1ed40f3 --- /dev/null +++ b/internal/teststep/raw.go @@ -0,0 +1,55 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package teststep + +import ( + "context" + "encoding/json" + "fmt" + "os" + "path/filepath" +) + +type configurationString struct { + raw string +} + +func (c configurationString) HasConfigurationFiles() bool { + return false +} + +// HasProviderBlock returns true if the Config has declared a provider +// configuration block, e.g. provider "examplecloud" {...} +func (c configurationString) HasProviderBlock(ctx context.Context) (bool, error) { + return providerConfigBlockRegex.MatchString(c.raw), nil +} + +// HasTerraformBlock returns true if the Config has declared a terraform +// configuration block, e.g. terraform {...} +func (c configurationString) HasTerraformBlock(ctx context.Context) (bool, error) { + return terraformConfigBlockRegex.MatchString(c.raw), nil +} + +func (c configurationString) Write(ctx context.Context, dest string) error { + outFilename := filepath.Join(dest, rawConfigFileName) + rmFilename := filepath.Join(dest, rawConfigFileNameJSON) + + bCfg := []byte(c.raw) + + if json.Valid(bCfg) { + outFilename, rmFilename = rmFilename, outFilename + } + + if err := os.Remove(rmFilename); err != nil && !os.IsNotExist(err) { + return fmt.Errorf("unable to remove %q: %w", rmFilename, err) + } + + err := os.WriteFile(outFilename, bCfg, 0700) + + if err != nil { + return err + } + + return nil +} diff --git a/internal/teststep/raw_test.go b/internal/teststep/raw_test.go new file mode 100644 index 000000000..3cddea220 --- /dev/null +++ b/internal/teststep/raw_test.go @@ -0,0 +1,120 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package teststep + +import ( + "context" + "testing" +) + +func TestConfiguration_HasProviderBlock(t *testing.T) { + t.Parallel() + + testCases := map[string]struct { + configRaw configurationString + expected bool + }{ + "no-config": { + expected: false, + }, + "provider-meta-attribute": { + configRaw: configurationString{ + raw: ` +resource "test_test" "test" { + provider = test.test +} +`, + }, + expected: false, + }, + "provider-object-attribute": { + configRaw: configurationString{ + raw: ` +resource "test_test" "test" { + test = { + provider = { + test = true + } + } +} +`, + }, + expected: false, + }, + "provider-string-attribute": { + configRaw: configurationString{ + raw: ` +resource "test_test" "test" { + test = { + provider = "test" + } +} +`, + }, + expected: false, + }, + "provider-block-quoted-with-attributes": { + configRaw: configurationString{ + raw: ` +provider "test" { + test = true +} + +resource "test_test" "test" {} +`, + }, + expected: true, + }, + "provider-block-unquoted-with-attributes": { + configRaw: configurationString{ + raw: ` +provider test { + test = true +} + +resource "test_test" "test" {} +`, + }, + expected: true, + }, + "provider-block-quoted-without-attributes": { + configRaw: configurationString{ + raw: ` +provider "test" {} + +resource "test_test" "test" {} +`, + }, + expected: true, + }, + "provider-block-unquoted-without-attributes": { + configRaw: configurationString{ + raw: ` +provider test {} + +resource "test_test" "test" {} +`, + }, + expected: true, + }, + } + + for name, testCase := range testCases { + name, testCase := name, testCase + + t.Run(name, func(t *testing.T) { + t.Parallel() + + got, err := testCase.configRaw.HasProviderBlock(context.Background()) + + if err != nil { + t.Errorf("unexpected error: %s", err) + } + + if testCase.expected != got { + t.Errorf("expected %t, got %t", testCase.expected, got) + } + }) + } +}