acceptance

package
v1.78.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountLevel added in v1.52.0

func AccountLevel(t *testing.T, steps ...Step)

func BuildImportStateIdFunc added in v1.52.0

func BuildImportStateIdFunc(resourceId, attr string) func(*terraform.State) (string, error)

BuildImportStateIdFunc constructs a function that returns the id attribute of a target resouce from the terraform state. This is a helper function for conveniently constructing the ImportStateIdFunc field for a test step.

func CreateUuid added in v1.65.0

func CreateUuid() string

func DefaultConfigCustomizer added in v1.71.0

func DefaultConfigCustomizer(cfg *config.Config) error

DefaultConfigCustomizer modifies the SDK configuration, setting the HTTP timeout to 10 minutes. Most APIs have a default timeout of 1 minute, but some have longer. Extending the HTTP timeout ensures that tests don't fail even if individual requests take longer than 1 minute.

func GetEnvInt64OrSkipTest added in v1.52.0

func GetEnvInt64OrSkipTest(t *testing.T, name string) int64

func GetEnvOrSkipTest added in v1.52.0

func GetEnvOrSkipTest(t *testing.T, name string) string

GetEnvOrSkipTest proceeds with test only with that env variable

func GetRunAsAttribute added in v1.65.0

func GetRunAsAttribute(t *testing.T, ctx context.Context) string

func IsAws added in v1.61.0

func IsAws(t *testing.T) bool

func IsAzure added in v1.61.0

func IsAzure(t *testing.T) bool

func IsGcp added in v1.61.0

func IsGcp(t *testing.T) bool

func LoadAccountEnv added in v1.61.0

func LoadAccountEnv(t *testing.T)

func LoadDebugEnvIfRunsFromIDE added in v1.65.0

func LoadDebugEnvIfRunsFromIDE(t *testing.T, key string)

loads debug environment from ~/.databricks/debug-env.json

func LoadUcacctEnv added in v1.61.0

func LoadUcacctEnv(t *testing.T)

func LoadUcwsEnv added in v1.61.0

func LoadUcwsEnv(t *testing.T)

func LoadWorkspaceEnv added in v1.61.0

func LoadWorkspaceEnv(t *testing.T)

func OidcConfigCustomizer added in v1.78.0

func OidcConfigCustomizer(cfg *config.Config) error

OidcConfigCustomizer customizes the SDK configuration to use OIDC when running in Github Actions without busting Go test caching. The Go test cache is busted when using OIDC because the URL and token in Github are different in each test run. The environment variables are cleared in the action to prevent the Go SDK from reading them during test runs. The resulting values are written to a hard-coded location, which we read from if present to use OIDC. It is not an error if these files are not present.

func PluginFrameworkProviderForTest added in v1.71.0

func PluginFrameworkProviderForTest(pluginFwOptions ...pluginfw.PluginFrameworkOption) provider.Provider

PluginFrameworkProviderForTest creates a test provider with the default config customizer.

func ProvidersWithResourceFallbacks added in v1.71.0

func ProvidersWithResourceFallbacks(resourceFallbacks []string) (*schema.Provider, provider.Provider)

ProvidersWithResourceFallbacks creates test providers, falling back to the SDKv2 provider for the specified resources. This is a convenience constructor that ensures that the resulting mux'ed provider uses the SDKv2 implementation for the specified resources.

func RandomEmail added in v1.52.0

func RandomEmail(prefix ...string) string

RandomEmail generates random email

func RandomHex added in v1.52.0

func RandomHex(prefix string, randLen int) string

func RandomName added in v1.52.0

func RandomName(prefix ...string) string

RandomName gives random name with optional prefix. e.g. qa.RandomName("tf-")

func ResourceCheck

func ResourceCheck(name string,
	cb func(ctx context.Context, client *common.DatabricksClient, id string) error) resource.TestCheckFunc

resourceCheck calls back a function with client and resource id

func ResourceCheckWithState added in v1.65.0

func ResourceCheckWithState(name string,
	cb func(ctx context.Context, client *common.DatabricksClient, state *terraform.InstanceState) error) resource.TestCheckFunc

resourceCheckWithState calls back a function with client and resource instance state

func SdkV2ProviderForTest added in v1.71.0

func SdkV2ProviderForTest(sdkV2Options ...sdkv2.SdkV2ProviderOption) *schema.Provider

SdkV2ProviderForTest creates a test provider with the default config customizer.

func Skipf added in v1.61.0

func Skipf(t *testing.T) func(format string, args ...any)

func UnityAccountLevel added in v1.52.0

func UnityAccountLevel(t *testing.T, steps ...Step)

func UnityWorkspaceLevel added in v1.52.0

func UnityWorkspaceLevel(t *testing.T, steps ...Step)

func WorkspaceLevel added in v1.52.0

func WorkspaceLevel(t *testing.T, steps ...Step)

Types

type Step

type Step struct {
	// Terraform HCL for resources to materialize in this test step.
	Template string

	// This function is called after the template is applied. Useful for making assertions
	// or doing cleanup.
	Check func(*terraform.State) error

	// Setup function called before the template is materialized.
	PreConfig func()

	Destroy                   bool
	Taint                     []string
	ExpectNonEmptyPlan        bool
	ExpectError               *regexp.Regexp
	ConfigPlanChecks          resource.ConfigPlanChecks
	PlanOnly                  bool
	PreventDiskCleanup        bool
	PreventPostDestroyRefresh bool

	// If true, will test the functionality of ImportState by importing the resource with ResourceName (must be set) and the ID of that resource.
	// ID can be supplied with either ImportStateId or ImportStateIdFunc.
	ImportState                          bool
	ImportStateId                        string
	ImportStateIdFunc                    func(*terraform.State) (string, error)
	ImportStateVerify                    bool
	ImportStateVerifyIdentifierAttribute string
	ResourceName                         string

	ProtoV6ProviderFactories map[string]func() (tfprotov6.ProviderServer, error)
}

A step in a terraform acceptance test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL