acceptance

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTestClient

func BuildTestClient() (*clients.Client, error)

func CheckDestroyedFunc

func CheckDestroyedFunc(client *clients.Client, testResource TestResource, resourceType, resourceName string) func(state *terraform.State) error

CheckDestroyedFunc returns a TestCheckFunc which validates the resource no longer exists

func PreCheck

func PreCheck(t *testing.T)

func RandInt

func RandInt() int

RandInt generates a random integer

func RandIntRange

func RandIntRange(min int, max int) int

RandIntRange returns a random integer between min (inclusive) and max (exclusive)

func RandStringFromCharSet

func RandStringFromCharSet(strlen int, charSet string) string

RandStringFromCharSet generates a random string by selecting characters from the charset provided

func RandTimeInt

func RandTimeInt() int

func RequiresImportError

func RequiresImportError(_ string) *regexp.Regexp

Types

type TestData

type TestData struct {
	// RandomInteger is a random integer which is unique to this test case
	RandomInteger int

	// RandomString is a random 5 character string is unique to this test case
	RandomString string

	// ResourceName is the fully qualified resource name, comprising of the
	// resource type and then the resource label
	// e.g. `azurerm_resource_group.test`
	ResourceName string

	// ResourceType is the Terraform Resource Type - `azurerm_resource_group`
	ResourceType string
	// contains filtered or unexported fields
}

func BuildTestData

func BuildTestData(t *testing.T, resourceType string, resourceLabel string) TestData

BuildTestData generates some test data for the given resource

func (TestData) DataSourceTest

func (td TestData) DataSourceTest(t *testing.T, steps []resource.TestStep)

lintignore:AT001

func (TestData) ImportStep

func (td TestData) ImportStep(ignore ...string) resource.TestStep

ImportStep returns a Test Step which Imports the Resource, optionally ignoring any fields which may not be imported (for example, as they're not returned from the API)

func (TestData) ImportStepFor

func (td TestData) ImportStepFor(resourceName string, ignore ...string) resource.TestStep

ImportStepFor returns a Test Step which Imports a given resource by name, optionally ignoring any fields which may not be imported (for example, as they're not returned from the API)

func (TestData) ImportStepWithImportStateIdFunc

func (td TestData) ImportStepWithImportStateIdFunc(importStateIdFunc resource.ImportStateIdFunc, ignore ...string) resource.TestStep

ImportStep returns a Test Step which Imports the Resource, optionally ignoring any fields which may not be imported (for example, as they're not returned from the API)

func (*TestData) RandomInt

func (td *TestData) RandomInt() int

RandomIntOfLength is a random 8 to 18 digit integer which is unique to this test case

func (*TestData) RandomStringOfLength

func (td *TestData) RandomStringOfLength(length int) string

func (TestData) RequiresImportErrorStep

func (td TestData) RequiresImportErrorStep(configBuilder func(data TestData) string) resource.TestStep

RequiresImportErrorStep returns a Test Step which expects a Requires Import error to be returned when running this step

func (TestData) ResourceTest

func (td TestData) ResourceTest(t *testing.T, testResource TestResource, steps []resource.TestStep)

func (TestData) RunAcceptanceTest added in v0.3.0

func (td TestData) RunAcceptanceTest(t *testing.T, testCase resource.TestCase)

func (TestData) UpgradeTest

func (td TestData) UpgradeTest(t *testing.T, testResource TestResource, steps []resource.TestStep)

func (TestData) UpgradeTestApplyStep

func (td TestData) UpgradeTestApplyStep(applyStep resource.TestStep) resource.TestStep

UpgradeTestApplyStep returns a test step used to run terraform apply with the development version

func (TestData) UpgradeTestDeployStep

func (td TestData) UpgradeTestDeployStep(step resource.TestStep, upgradeFrom string) resource.TestStep

UpgradeTestDeployStep returns a test step used to deploy the configuration with previous version

func (TestData) UpgradeTestPlanStep

func (td TestData) UpgradeTestPlanStep(planStep resource.TestStep) resource.TestStep

UpgradeTestPlanStep returns a test step used to run terraform plan with the development version to check if there's any changes

type TestResource

type TestResource interface {
	Exists(ctx context.Context, client *clients.Client, state *terraform.InstanceState) (*bool, error)
}

type TestResourceVerifyingRemoved

type TestResourceVerifyingRemoved interface {
	TestResource
	Destroy(ctx context.Context, client *clients.Client, state *terraform.InstanceState) (*bool, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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