testutils

package
v0.62.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Prefix                         = "test-terraform-exoscale"
	TestUsername                   = "test-exo-username"
	TestDescription                = "Created by the terraform-exoscale provider"
	TestZoneName                   = "bg-sof-1"
	TestInstanceTemplateName       = "Linux Ubuntu 20.04 LTS 64-bit"
	TestInstanceTemplateUsername   = "ubuntu"
	TestInstanceTemplateFilter     = "featured"
	TestInstanceTemplateVisibility = "public"

	TestInstanceTypeIDTiny   = "b6cd1ff5-3a2f-4e9d-a4d1-8988c1191fe8"
	TestInstanceTypeIDSmall  = "21624abb-764e-4def-81d7-9fc54b5957fb"
	TestInstanceTypeIDMedium = "b6e9d1e8-89fc-4db3-aaa4-9b4c5b1d0844"
)

Variables

View Source
var TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
	"exoscale": func() (tfprotov6.ProviderServer, error) {
		ctx := context.Background()
		upgradedProvider, err := tf5to6server.UpgradeServer(
			ctx,
			exoscale.Provider().GRPCProvider,
		)
		if err != nil {
			return nil, err
		}

		newProvider := providerserver.NewProtocol6(&provider.ExoscaleProvider{})

		providers := []func() tfprotov6.ProviderServer{
			func() tfprotov6.ProviderServer {
				return upgradedProvider
			},
			newProvider,
		}

		return tf6muxserver.NewMuxServer(ctx, providers...)
	},
}

TestAccProtoV6ProviderFactories are used to instantiate a provider during acceptance testing. The factory function will be invoked for every Terraform CLI command executed to create a provider server to which the CLI can reattach.

Functions

func APIClient

func APIClient() (*egoscale.Client, error)

func AccPreCheck

func AccPreCheck(t *testing.T)

func AttrFromState

func AttrFromState(s *terraform.State, r, a string) (string, error)

AttrFromState returns the value of the attribute a for the resource r from the current global state s.

func CheckAntiAffinityGroupDestroy

func CheckAntiAffinityGroupDestroy(res *egoscale.AntiAffinityGroup) resource.TestCheckFunc

func CheckAntiAffinityGroupExists

func CheckAntiAffinityGroupExists(r string, res *egoscale.AntiAffinityGroup) resource.TestCheckFunc

func CheckElasticIPDestroy

func CheckElasticIPDestroy(elasticIP *egoscale.ElasticIP) resource.TestCheckFunc

func CheckElasticIPExists

func CheckElasticIPExists(r string, elasticIP *egoscale.ElasticIP) resource.TestCheckFunc

func CheckInstanceDestroy

func CheckInstanceDestroy(testInstance *egoscale.Instance) resource.TestCheckFunc

func CheckInstanceExists

func CheckInstanceExists(r string, testInstance *egoscale.Instance) resource.TestCheckFunc

func CheckInstancePoolDestroy

func CheckInstancePoolDestroy(pool *egoscale.InstancePool) resource.TestCheckFunc

func CheckInstancePoolExists

func CheckInstancePoolExists(r string, pool *egoscale.InstancePool) resource.TestCheckFunc

func CheckPrivateNetworkDestroy

func CheckPrivateNetworkDestroy(privateNetwork *egoscale.PrivateNetwork) resource.TestCheckFunc

func CheckPrivateNetworkExists

func CheckPrivateNetworkExists(r string, privateNetwork *egoscale.PrivateNetwork) resource.TestCheckFunc

func CheckResourceAttributes

func CheckResourceAttributes(want TestAttrs, got map[string]string) error

checkResourceAttributes compares a map of resource attributes against a map of expected resource attributes and performs validation on the values.

func CheckResourceState

func CheckResourceState(r string, tests ...TestResourceStateValidationFunc) resource.TestCheckFunc

checkResourceState executes the specified TestResourceStateValidationFunc functions against the state of the resource matching the specified identifier r (e.g. "exoscale_compute.test"), and returns an error if any test function returns an error.

func CheckSSHKeyDestroy

func CheckSSHKeyDestroy(sshKey *egoscale.SSHKey) resource.TestCheckFunc

func CheckSSHKeyExists

func CheckSSHKeyExists(r string, sshKey *egoscale.SSHKey) resource.TestCheckFunc

func CheckSecurityGroupDestroy

func CheckSecurityGroupDestroy(securityGroup *egoscale.SecurityGroup) resource.TestCheckFunc

func CheckSecurityGroupExists

func CheckSecurityGroupExists(r string, securityGroup *egoscale.SecurityGroup) resource.TestCheckFunc

func ParseTestdataConfig added in v0.58.0

func ParseTestdataConfig(path string, spec *TestdataSpec) string

ParseTestdataConfig loads configuration template and replaces Zone and test ID placeholders. To reduce some error handling boilerplate funcion panics on failure to parse the template.

func Providers

func Providers() map[string]func() (*schema.Provider, error)

Providers returns all providers used during acceptance testing.

func TestEnvironment

func TestEnvironment() string

func ValidateComputeInstanceType

func ValidateComputeInstanceType(v interface{}, _ cty.Path) diag.Diagnostics

ValidateComputeInstanceType validates that the given field contains a valid Exoscale Compute instance type.

func ValidateComputeUserData

func ValidateComputeUserData(v interface{}, _ cty.Path) diag.Diagnostics

ValidateComputeUserData validates that the given field contains a valid data.

func ValidatePortRange

func ValidatePortRange(i interface{}, k string) (s []string, es []error)

ValidatePortRange validates that the given field contains a port range.

func ValidateString

func ValidateString(str string) schema.SchemaValidateDiagFunc

ValidateString validates that the given field is a string and matches the expected value.

Types

type DataSourceNlbServiceListModel added in v0.52.0

type DataSourceNlbServiceListModel struct {
	ResourceName string

	Zone string
	ID   string
	Name string

	RawConfig string
}

DataSourceNlbServiceListModel maps to datasource_nlb_service_list.tmpl

type DataSourceTemplateModel added in v0.52.0

type DataSourceTemplateModel struct {
	ResourceName string

	Zone       string
	ID         string
	Name       string
	Visibility string
}

DataSourceTemplateModel maps to datasource_template.tmpl

type ResourceAPIKeyModel added in v0.53.0

type ResourceAPIKeyModel struct {
	ResourceName string

	Name   string
	RoleID string
}

ResourceAPIKeyModel maps to resource_iam_api_key.tmpl

type ResourceIAMOrgPolicyModel added in v0.53.0

type ResourceIAMOrgPolicyModel struct {
	ResourceName string

	DefaultServiceStrategy string
	Services               map[string]ResourceIAMPolicyServicesModel
}

ResourceIAMOrgPolicyModel maps to resource_iam_org_policy.tmpl

type ResourceIAMPolicyServiceRules added in v0.53.0

type ResourceIAMPolicyServiceRules struct {
	Action     string
	Expression string
	Resources  string
}

ResourceIAMPolicyServiceRules defines nested structure within IAM Policy Service.

type ResourceIAMPolicyServicesModel added in v0.53.0

type ResourceIAMPolicyServicesModel struct {
	Type  string
	Rules []ResourceIAMPolicyServiceRules
}

ResourceIAMPolicyServicesModel defines nested structure within IAM Policy.

type ResourceIAMRole added in v0.53.0

type ResourceIAMRole struct {
	ResourceName string

	Name        string
	Description string
	Editable    bool
	Labels      map[string]string
	Permissions string

	Policy *ResourceIAMOrgPolicyModel
}

ResourceIAMRole maps to resource_iam_role.tmpl

type ResourceInstancePoolModel added in v0.52.0

type ResourceInstancePoolModel struct {
	ResourceName string

	Zone       string
	Name       string
	Size       int64
	TemplateID string
	Type       string
	DiskSize   int64
}

ResourceInstancePoolModel maps to resource_instance_pool.tmpl

type ResourceNLBModel added in v0.52.0

type ResourceNLBModel struct {
	ResourceName string

	Zone        string
	Name        string
	Description string
	Labels      string
}

ResourceNLBModel maps to resource_nlb.tmpl

type ResourceNLBServiceModel added in v0.52.0

type ResourceNLBServiceModel struct {
	ResourceName string

	Zone                string
	Name                string
	NLBID               string
	InstancePoolID      string
	Port                int64
	TargetPort          int64
	Description         string
	Protocol            string
	Strategy            string
	HealthcheckPort     int64
	HealthcheckInterval int64
	HealthcheckMode     string
	HealthcheckRetries  int64
	HealthcheckTimeout  int64
	HealthcheckTLSSNI   string
	HealthcheckURI      string
}

ResourceNLBServiceModel maps to resource_nlb_service.tmpl

type TestAttrs

type TestAttrs map[string]schema.SchemaValidateDiagFunc

testAttrs represents a map of expected resource attributes during acceptance tests.

type TestResourceStateValidationFunc

type TestResourceStateValidationFunc func(state *terraform.InstanceState) error

testResourceStateValidationFunc represents a resource state validation function.

func CheckResourceStateValidateAttributes

func CheckResourceStateValidateAttributes(want TestAttrs) TestResourceStateValidationFunc

CheckResourceStateValidateAttributes compares a map of resource attributes against a map of expected resource attributes and performs validation on the values.

type TestdataSpec added in v0.58.0

type TestdataSpec struct {
	ID   int64
	Zone string
}

TestdataSpec embeds ID/Zone into testdata templates.

Jump to

Keyboard shortcuts

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