acctest

package
v2.45.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MPL-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestDomain     = ""
	TestDomainZone = ""
)
View Source
var BodyMatcherIgnore = []string{
	"organization",
	"organization_id",
	"project_id",
	"project",
}

BodyMatcherIgnore contains the list of json body keys that should be ignored when matching requests with cassettes

View Source
var QueryMatcherIgnore = []string{
	"organization_id",
}

QueryMatcherIgnore contains the list of query value that should be ignored when matching requests with cassettes

View Source
var SensitiveFields = map[string]interface{}{
	"secret_key": "00000000-0000-0000-0000-000000000000",
}

SensitiveFields is a map with keys listing fields that should be anonymized value will be set in place of its old value

View Source
var UUIDRegex = regexp.MustCompile(`[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}`)
View Source
var UpdateCassettes = flag.Bool("cassettes", os.Getenv("TF_UPDATE_CASSETTES") == "true", "Record Cassettes")

UpdateCassettes will update all cassettes of a given test

Functions

func CheckResourceAttrFunc added in v2.39.0

func CheckResourceAttrFunc(name string, key string, test func(string) error) resource.TestCheckFunc

func CheckResourceAttrIP added in v2.39.0

func CheckResourceAttrIP(name string, key string) resource.TestCheckFunc

func CheckResourceAttrIPv4 added in v2.39.0

func CheckResourceAttrIPv4(name string, key string) resource.TestCheckFunc

func CheckResourceAttrIPv6 added in v2.39.0

func CheckResourceAttrIPv6(name string, key string) resource.TestCheckFunc

func CheckResourceAttrUUID added in v2.39.0

func CheckResourceAttrUUID(name string, key string) resource.TestCheckFunc

func CheckResourceIDChanged

func CheckResourceIDChanged(resourceName string, resourceID *string) resource.TestCheckFunc

CheckResourceIDChanged checks that the ID of the resource has indeed changed, in case of ForceNew for example. It will fail if resourceID is empty so be sure to use acctest.CheckResourceIDPersisted first in a test suite.

func CheckResourceIDPersisted

func CheckResourceIDPersisted(resourceName string, resourceID *string) resource.TestCheckFunc

CheckResourceIDPersisted checks that the ID of the resource is the same throughout tests of migration or mutation It can be used to check that no ForceNew has been done

func CheckResourceRawIDMatches

func CheckResourceRawIDMatches(res1, attr1, res2, attr2 string) resource.TestCheckFunc

CheckResourceRawIDMatches asserts the equality of IDs from two specified attributes of two Scaleway resources.

func FakeSideProjectProviders added in v2.39.0

func FakeSideProjectProviders(ctx context.Context, tt *TestTools, project *account.Project, iamAPIKey *iam.APIKey) map[string]func() (*schema.Provider, error)

FakeSideProjectProviders creates a new provider alias "side" with a new Config that will use the given project and API key as default profile configuration.

This is useful to test resources that need to create resources in another project.

func IsTestResource added in v2.39.0

func IsTestResource(identifier string) bool

IsTestResource returns true if given resource identifier is from terraform test identifier should be resource name but some resource don't have names return true if identifier match regex "tf[-_]test" common used prefixes are "tf_tests", "tf_test", "tf-tests", "tf-test"

func PreCheck

func PreCheck(_ *testing.T)

func Sweep added in v2.39.0

func Sweep(f func(scwClient *scw.Client) error) error

func SweepRegions added in v2.39.0

func SweepRegions(regions []scw.Region, f func(scwClient *scw.Client, region scw.Region) error) error

func SweepZones added in v2.39.0

func SweepZones(zones []scw.Zone, f func(scwClient *scw.Client, zone scw.Zone) error) error

Types

type FakeSideProjectTerminateFunc added in v2.39.0

type FakeSideProjectTerminateFunc func() error

func CreateFakeIAMManager added in v2.39.0

func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSideProjectTerminateFunc, error)

CreateFakeIAMManager creates a temporary project with a temporary IAM application and policy manager.

The returned function is a cleanup function that should be called when to delete the project.

func CreateFakeSideProject added in v2.39.0

func CreateFakeSideProject(tt *TestTools) (*account.Project, *iam.APIKey, FakeSideProjectTerminateFunc, error)

CreateFakeSideProject creates a temporary project with a temporary IAM application and policy.

The returned function is a cleanup function that should be called when to delete the project.

type TestTools

type TestTools struct {
	T                 *testing.T
	Meta              *meta.Meta
	ProviderFactories map[string]func() (*schema.Provider, error)
	Cleanup           func()
}

func NewTestTools

func NewTestTools(t *testing.T) *TestTools

Jump to

Keyboard shortcuts

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