Documentation ¶
Index ¶
- Variables
- func GenerateTestChecks(ctx context.Context, tacc TestACC, resourceName string, testName TestName) []resource.TestCheckFunc
- func GenerateTests(tacc TestACC) []resource.TestStep
- func GetValueFromTemplate(resourceName, key string) string
- func ImportStateIDBuilder(resourceName string, attributeNames []string) resource.ImportStateIdFunc
- type DependenciesConfigResponse
- type ListOfDependencies
- type ResourceName
- type TFACCLog
- type TFAdvanced
- type TFConfig
- type TFData
- type TFImport
- type Test
- type TestACC
- type TestName
Constants ¶
This section is empty.
Variables ¶
var (
KeyValueStore = &map[string]any{}
)
Functions ¶
func GenerateTestChecks ¶ added in v0.12.0
func GenerateTestChecks(ctx context.Context, tacc TestACC, resourceName string, testName TestName) []resource.TestCheckFunc
GenerateTestChecks Generate the checks for a specific test.
func GenerateTests ¶
GenerateTests generates the acceptance tests for the resource under test.
func GetValueFromTemplate ¶ added in v0.11.0
GetValueFromTemplate returns the value of the given key from the key-value store.
func ImportStateIDBuilder ¶
func ImportStateIDBuilder(resourceName string, attributeNames []string) resource.ImportStateIdFunc
ImportStateIDBuilder is a function that can be used to dynamically generate the ID for the ImportState tests. It is sent the state, which can be checked to derive the attributes necessary and generate the string in the desired format. Specifie the list of attribute names to use to build the ID. Example of use: []string{"vdc_name", "edgegateway_name"} => "vdcExample.edgegatewayExample".
Types ¶
type DependenciesConfigResponse ¶ added in v0.15.0
type DependenciesConfigResponse []func() TFData
func (*DependenciesConfigResponse) Append ¶ added in v0.15.0
func (d *DependenciesConfigResponse) Append(tf func() TFData)
* DependenciesConfigResponse Append appends the given dependencies config to the current one.
type ListOfDependencies ¶ added in v0.11.0
type ListOfDependencies []ResourceName
func (*ListOfDependencies) Append ¶ added in v0.11.0
func (l *ListOfDependencies) Append(resourceName ResourceName)
* ListOfDependencies Append appends the given dependency to the list of dependencies. resourceName is a concatenation of the resource name and the name. For example, "cloudavenue_catalog.example".
func (*ListOfDependencies) Exists ¶ added in v0.11.0
func (l *ListOfDependencies) Exists(resourceName ResourceName) bool
Exists checks if the given dependency exists in the list of dependencies. resourceName is a concatenation of the resource name and the name. For example, "cloudavenue_catalog.example".
type ResourceName ¶ added in v0.11.0
type ResourceName string
func (ResourceName) String ¶ added in v0.11.0
func (r ResourceName) String() string
* ResourceName String returns the string representation of the ResourceName.
type TFACCLog ¶ added in v0.15.0
type TFACCLog struct {
Level string `env:"LEVEL,default=info"`
}
TODO : Add TFACCLog management.
type TFAdvanced ¶ added in v0.12.0
type TFAdvanced struct { // PreConfig is called before the Config is applied to perform any per-step // setup that needs to happen. This is called regardless of "test mode" // below. PreConfig func() // Taint is a list of resource addresses to taint prior to the execution of // the step. Be sure to only include this at a step where the referenced // address will be present in state, as it will fail the test if the resource // is missing. // // This option is ignored on ImportState tests, and currently only works for // resources in the root module path. Taint []string // Destroy will create a destroy plan if set to true. Destroy bool // ExpectNonEmptyPlan can be set to true for specific types of tests that are // looking to verify that a diff occurs ExpectNonEmptyPlan bool // ExpectError allows the construction of test cases that we expect to fail // with an error. The specified regexp must match against the error for the // test to pass. ExpectError *regexp.Regexp // PlanOnly can be set to only run `plan` with this configuration, and not // actually apply it. This is useful for ensuring config changes result in // no-op plans PlanOnly bool // PreventDiskCleanup can be set to true for testing terraform modules which // require access to disk at runtime. Note that this will leave files in the // temp folder PreventDiskCleanup bool // PreventPostDestroyRefresh can be set to true for cases where data sources // are tested alongside real resources PreventPostDestroyRefresh bool }
func (*TFAdvanced) IsEmpty ¶ added in v0.12.0
func (t *TFAdvanced) IsEmpty() bool
IsEmpty returns true if the TFAdvanced is empty.
type TFConfig ¶
type TFConfig struct { // Checks is a Terraform checks to run for checking the resource under test. // If EnableAutoCheck is true, these checks will be automatically added to the test. // If EnableAutoCheck is false, these checks will be the only checks run for the test. Checks []resource.TestCheckFunc // TFCongig is the Terraform configuration to use for the test. TFConfig TFData // TFAdvanced is the Terraform advanced configuration to use for the test. TFAdvanced TFAdvanced }
type TFData ¶
type TFData string
func GenerateFromTemplate ¶ added in v0.11.0
GenerateFromTemplate generates the Terraform configuration from the given template. The template can contain placeholders that will be replaced by the given values.
Who to use:
resource "cloudavenue_catalog" "example" { name = {{ get . "name" }} description = {{ generate . "description" "longString"}} delete_recursive = true delete_force = true }
Available functions in the template:
- generate: generates a random string and stores it in the key-value store. Generate accepts an optional argument that specifies the format of the random string (available formats: "shortString", "longString"). Default format is "shortString".
- get: returns the value of the given key from the key-value store.
func (*TFData) AppendWithoutResourceName ¶ added in v0.11.0
AppendWithoutResourceName appends the given Terraform configuration to the current one.
type TFImport ¶
type TFImport struct { // ImportStateId is the ID to perform an ImportState operation with. // This is optional. If it isn't set, then the resource ID is automatically // determined by inspecting the state for ResourceName's ID. ImportStateID string // ImportStateIdFunc is a function that can be used to dynamically generate // the ID for the ImportState tests. It is sent the state, which can be // checked to derive the attributes necessary and generate the string in the // desired format. ImportStateIDFunc resource.ImportStateIdFunc // ImportStateIDBuilder is a function that can be used to dynamically generate // the ID for the ImportState tests. It is sent the state, which can be // checked to derive the attributes necessary and generate the string in the // desired format. // Specifie the list of attribute names to use to build the ID. // Example of use: []string{"vdc_name", "edgegateway_name"} => "vdcExample.edgegatewayExample" ImportStateIDBuilder []string // ImportStateVerifyIgnore is a list of prefixes of fields that should // not be verified to be equal. These can be set to ephemeral fields or // fields that can't be refreshed and don't matter. ImportStateVerifyIgnore []string // ImportStatePersist, if true, will update the persisted state with the // state generated by the import operation (i.e., terraform import). When // false (default) the state generated by the import operation is discarded // at the end of the test step that is verifying import behavior. ImportStatePersist bool // ImportStateVerify, if true, will also check that the state values // that are finally put into the state after import match for all the // IDs returned by the Import. ImportStateVerify bool // ImportState, if true, will test the functionality of ImportState // by importing the resource with ID of that resource. ImportState bool }
type Test ¶
type Test struct { // CommonChecks is a list of common Terraform checks applied to all tests. CommonChecks []resource.TestCheckFunc // Create returns the Terraform configuration to use for the test. // This should be a valid Terraform configuration that can be used to create, update, and destroy resources. Create TFConfig // Update returns the Terraform configurations to use for the update test. // This should be a valid Terraform configuration that can be used to update the resource under test. Updates []TFConfig // Import returns the Terraform configurations to use for the import test. Imports []TFImport // Destroy will create a destroy plan if set to true. Destroy bool // CacheDependenciesConfig is used to cache the dependencies config. CacheDependenciesConfig TFData // contains filtered or unexported fields }
func (*Test) ComputeDependenciesConfig ¶ added in v0.15.0
Compute Dependencies config.
func (Test) GenerateCheckWithCommonChecks ¶
func (t Test) GenerateCheckWithCommonChecks() []resource.TestCheckFunc
GenerateCheckWithCommonChecks concatenates the common checks and the specific checks.
type TestACC ¶
type TestACC interface { // GetResourceName returns the name of the resource under test. GetResourceName() string // DependenciesConfig returns the Terraform configuration used to create any dependencies of the resource under test. DependenciesConfig() DependenciesConfigResponse // Tests returns the acceptance tests to run for the resource under test. // resourceName is a concatenation of the resource name and the example name. For example, "cloudavenue_catalog.example". Tests(context.Context) map[TestName]func(ctx context.Context, resourceName string) Test }