acceptance

package
v2.85.6 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComposeAggregateTestCheckFunc

func ComposeAggregateTestCheckFunc(fs ...resource.TestCheckFunc) pluginsdk.TestCheckFunc

func ComposeTestCheckFunc

func ComposeTestCheckFunc(fs ...resource.TestCheckFunc) pluginsdk.TestCheckFunc

func Environment

func Environment() (*azure.Environment, error)

func EnvironmentName

func EnvironmentName() string

func GetAuthConfig

func GetAuthConfig(t *testing.T) *authentication.Config

func PreCheck

func PreCheck(t *testing.T)

func RandString

func RandString(strlen int) string

RandString generates a random alphanumeric string of the length specified

func RandStringFromCharSet

func RandStringFromCharSet(strlen int, charSet string) string

func RandTimeInt

func RandTimeInt() int

func RequiresImportError

func RequiresImportError(resourceName string) *regexp.Regexp

func RunTestsInSequence

func RunTestsInSequence(t *testing.T, tests map[string]map[string]func(t *testing.T))

func TestCheckNoResourceAttr

func TestCheckNoResourceAttr(name, key string) resource.TestCheckFunc

TestCheckNoResourceAttr is a TestCheckFunc which ensures that NO value exists in state for the given name/key combination.

func TestCheckOutput

func TestCheckOutput(name, value string) pluginsdk.TestCheckFunc

TestCheckOutput is a wrapper to enable builds to continue

func TestCheckResourceAttr

func TestCheckResourceAttr(name, key, value string) pluginsdk.TestCheckFunc

TestCheckResourceAttr is a wrapper to enable builds to continue

func TestCheckResourceAttrPair

func TestCheckResourceAttrPair(nameFirst, keyFirst, nameSecond, keySecond string) resource.TestCheckFunc

TestCheckResourceAttrPair is a TestCheckFunc which validates that the values in state for a pair of name/key combinations are equal.

func TestCheckResourceAttrSet

func TestCheckResourceAttrSet(name, key string) pluginsdk.TestCheckFunc

func TestMatchOutput

func TestMatchOutput(name string, r *regexp.Regexp) pluginsdk.TestCheckFunc

TestMatchOutput is a wrapper to enable builds to continue

func TestMatchResourceAttr

func TestMatchResourceAttr(name, key string, r *regexp.Regexp) pluginsdk.TestCheckFunc

TestMatchResourceAttr is a TestCheckFunc which checks that the value in state for the given name/key combination matches the given regex.

Types

type ClientAuthDetails

type ClientAuthDetails struct {
	// ClientID is the UUID of the Service Principal being used to connect to Azure
	ClientID string

	// ClientSecret is the Client Secret being used to connect to Azure
	ClientSecret string
}

type ClientCheckFunc

type ClientCheckFunc func(ctx context.Context, clients *clients.Client, state *terraform.InstanceState) error

type ClientData

type ClientData struct {
	// Default is the Default Credentials being used to connect to Azure
	Default ClientAuthDetails

	// Alternate is an alternate set of Credentials being used to connect to Azure
	Alternate ClientAuthDetails

	// SubscriptionID is the UUID of the Azure Subscription where tests are being run
	SubscriptionID string

	// SubscriptionIDAlt is the UUID of the Alternate Azure Subscription where tests are being run
	SubscriptionIDAlt string

	// TenantID is the UUID of the Azure Tenant where tests are being run
	TenantID string

	// Are we connected as a Service Principal
	// this exists for allowing folks to run the test suite via other
	// credentials in the future; but requires code changes first
	IsServicePrincipal bool
}

type DisappearsStepData

type DisappearsStepData struct {
	// Config is a function which returns the Terraform Configuration which should be used for this step
	Config func(data TestData) string

	// TestResource is a reference to a TestResource which can destroy the resource
	// to enable a Disappears step
	TestResource types.TestResourceVerifyingRemoved
}

type InstanceState

type InstanceState = terraform.InstanceState

type Regions

type Regions struct {
	// Primary is the Primary/Default Azure Region which should be used for testing
	Primary string

	// Secondary is the Secondary Azure Region which should be used for testing
	Secondary string

	// Ternary is the Ternary Azure Region which should be used for testing
	Ternary string
}

Regions is a list of Azure Regions which can be used for test purposes

type State

type State = terraform.State

type StateChangeConf

type StateChangeConf = resource.StateChangeConf

type TestCheckFunc

type TestCheckFunc = resource.TestCheckFunc

type TestData

type TestData struct {
	// Locations is a set of Azure Regions which should be used for this Test
	Locations Regions

	// 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

	// Environment is a struct containing Details about the Azure Environment
	// that we're running against
	Environment azure.Environment

	// EnvironmentName is the name of the Azure Environment where we're running
	EnvironmentName string

	// MetadataURL is the url of the endpoint where the environment is obtained
	MetadataURL 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) CheckWithClient

func (td TestData) CheckWithClient(check ClientCheckFunc) resource.TestCheckFunc

CheckWithClient returns a TestCheckFunc which will call a ClientCheckFunc with the provider context and clients

func (TestData) CheckWithClientForResource

func (td TestData) CheckWithClientForResource(check ClientCheckFunc, resourceName string) resource.TestCheckFunc

CheckWithClientForResource returns a TestCheckFunc which will call a ClientCheckFunc with the provider context and clients for the named resource

func (TestData) CheckWithClientWithoutResource

func (td TestData) CheckWithClientWithoutResource(check ClientCheckFunc) resource.TestCheckFunc

CheckWithClientWithoutResource returns a TestCheckFunc which will call a ClientCheckFunc with the provider context and clients to find if a resource exists when the resource that created it is destroyed.

func (TestData) Client

func (td TestData) Client() ClientData

Client returns a struct containing information about the Client being used to connect to Azure

func (TestData) DataSourceTest

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

lintignore:AT001

func (TestData) DataSourceTestInSequence

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

lintignore:AT001

func (TestData) DisappearsStep

func (td TestData) DisappearsStep(data DisappearsStepData) resource.TestStep

DisappearsStep returns a Test Step which first confirms the resource exists then destroys it, and expects that the plan at the end of this should show that the resource needs to be created (since it's been destroyed)

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) RandomIntOfLength

func (td *TestData) RandomIntOfLength(len int) int

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

func (*TestData) RandomStringOfLength

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

RandomStringOfLength is a random 1 to 1024 character string which is unique to this test case

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) ResourceSequentialTest

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

func (TestData) ResourceSequentialTestSkipCheckDestroyed

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

lintignore:AT001

func (TestData) ResourceTest

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

lintignore:AT001

func (TestData) ResourceTestSkipCheckDestroyed

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

ResourceTestIgnoreCheckDestroyed skips the check to confirm the resource test has been destroyed. This is done because certain resources can't actually be deleted. lintignore:AT001

type TestStep

type TestStep = resource.TestStep

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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