A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing@v1.13.2/internal/plugintest below:

plugintest package - github.com/hashicorp/terraform-plugin-testing/internal/plugintest - Go Packages

Package plugintest contains utilities to help with writing tests for Terraform plugins.

This is not a package for testing configurations or modules written in the Terraform language. It is for testing the plugins that allow Terraform to manage various cloud services and other APIs.

View Source
const (
	
	
	
	
	
	
	EnvTfAccTempDir = "TF_ACC_TEMP_DIR"

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	EnvTfAccLog = "TF_ACC_LOG"

	
	
	
	
	
	
	EnvTfAccLogPath = "TF_ACC_LOG_PATH"

	
	
	
	
	
	
	
	
	
	EnvTfLogCore = "TF_LOG_CORE"

	
	
	
	
	
	
	
	EnvTfLogPathMask = "TF_LOG_PATH_MASK"

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	EnvTfLogProvider = "TF_LOG_PROVIDER"

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	EnvTfAccTerraformVersion = "TF_ACC_TERRAFORM_VERSION"

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	EnvTfAccTerraformPath = "TF_ACC_TERRAFORM_PATH"

	
	
	
	
	
	
	EnvTfAccPersistWorkingDir = "TF_ACC_PERSIST_WORKING_DIR"
)

Environment variables

View Source
const (
	ConfigFileName = "terraform_plugin_test.tf"
	PlanFileName   = "tfplan"
)

This section is empty.

CopyDir recursively copies directories and files from src to dest.

CopyFile copies a single file from src to dest.

func TestExpectTFatal(t *testing.T, testLogic func())

TestExpectTFatal provides a wrapper for logic which should call (*testing.T).Fatal() or (*testing.T).Fatalf().

Since we do not want the wrapping test to fail when an expected test error occurs, it is required that the testLogic passed in uses github.com/mitchellh/go-testing-interface.RuntimeT instead of the real *testing.T.

If Fatal() or Fatalf() is not called in the logic, the real (*testing.T).Fatal() will be called to fail the test.

Config is used to configure the test helper. In most normal test programs the configuration is discovered automatically by an Init* function using DiscoverConfig, but this is exposed so that more complex scenarios can be implemented by direct configuration.

DiscoverConfig uses environment variables and other means to automatically discover a reasonable test helper configuration.

Helper is intended as a per-package singleton created in TestMain which other tests in a package can use to create Terraform execution contexts

AutoInitHelper uses the auto-discovery behavior of DiscoverConfig to prepare a configuration and then calls InitHelper with it. This is a convenient way to get the standard init behavior based on environment variables, and callers should use this unless they have an unusual requirement that calls for constructing a config in a different way.

AutoInitProviderHelper is the main entrypoint for testing provider plugins using this package. It is intended to be called during TestMain to prepare for provider testing.

AutoInitProviderHelper will discover the location of a current Terraform CLI executable to test against, detect whether a prior version of the plugin is available for upgrade tests, and then will return an object containing the results of that initialization which can then be stored in a global variable for use in other tests.

InitHelper prepares a testing helper with the given configuration.

For most callers it is sufficient to call AutoInitHelper instead, which will construct a configuration automatically based on certain environment variables.

If this function returns an error then it may have left some temporary files behind in the system's temporary directory. There is currently no way to automatically clean those up.

Close cleans up temporary files and directories created to support this helper, returning an error if any of the cleanup fails.

Call this before returning from TestMain to minimize the amount of detritus left behind in the filesystem after the tests complete.

NewWorkingDir creates a new working directory for use in the implementation of a single test, returning a WorkingDir object representing that directory.

If the working directory object is not itself closed by the time the test program exits, the Close method on the helper itself will attempt to delete it.

RequireNewWorkingDir is a variant of NewWorkingDir that takes a TestControl object and will immediately fail the running test if the creation of the working directory fails.

TerraformExecPath returns the location of the Terraform CLI executable that should be used when running tests.

func (h *Helper) TerraformVersion() *version.Version

TerraformVersion returns the Terraform CLI version being used when running tests.

WorkingDirectory returns the working directory being used when running tests.

type TestControl interface {
	Helper()
	Log(args ...interface{})
	FailNow()
	SkipNow()
	Name() string
}

TestControl is an interface requiring a subset of *testing.T which is used by the test guards and helpers in this package. Most callers can simply pass their *testing.T value here, but the interface allows other implementations to potentially be provided instead, for example to allow meta-testing (testing of the test utilities themselves).

This interface also describes the subset of normal test functionality the guards and helpers can perform: they can only create log lines, fail tests, and skip tests. All other test control is the responsibility of the main test code.

type WorkingDir struct {
	
}

WorkingDir represents a distinct working directory that can be used for running tests. Each test should construct its own WorkingDir by calling NewWorkingDir or RequireNewWorkingDir on its package's singleton plugintest.Helper.

Apply runs "terraform apply". If CreatePlan has previously completed successfully and the saved plan has not been cleared in the meantime then this will apply the saved plan. Otherwise, it will implicitly create a new plan and apply it.

BaseDir returns the path to the root of the working directory tree.

ClearPlan deletes any saved plan present in the working directory.

ClearState deletes any Terraform state present in the working directory.

Any remote objects tracked by the state are not destroyed first, so this will leave them dangling in the remote system.

Close deletes the directories and files created to represent the receiving working directory. After this method is called, the working directory object is invalid and may no longer be used.

CreatePlan runs "terraform plan" to create a saved plan file, which if successful will then be used for the next call to Apply.

Destroy runs "terraform destroy". It does not consider or modify any saved plan, and is primarily for cleaning up at the end of a test run.

If destroy fails then remote objects might still exist, and continue to exist after a particular test is concluded.

GetHelper returns the Helper set on the WorkingDir.

HasSavedPlan returns true if there is a saved plan in the working directory. If so, a subsequent call to Apply will apply that saved plan.

Import runs terraform import

Init runs "terraform init" for the given working directory, forcing Terraform to use the current version of the plugin under test.

Refresh runs terraform refresh

RemoveResource removes a resource from state.

SavedPlan returns an object describing the current saved plan file, if any.

If no plan is saved or if the plan file cannot be read, SavedPlan returns an error.

SavedPlanRawStdout returns a human readable stdout capture of the current saved plan file, if any.

If no plan is saved or if the plan file cannot be read, SavedPlanRawStdout returns an error.

Schemas returns an object describing the provider schemas.

If the schemas cannot be read, Schemas returns an error.

SetConfig sets a new configuration for the working directory.

This must be called at least once before any call to Init, Plan, Apply, or Destroy to establish the configuration. Any previously-set configuration is discarded and any saved plan is cleared.

If the state cannot be read, State returns an error.

Taint runs terraform taint


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4