testutils

package
v0.0.23-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CdnCustomEndpoint             = os.Getenv("TF_ACC_CDN_CUSTOM_ENDPOINT")
	DnsCustomEndpoint             = os.Getenv("TF_ACC_DNS_CUSTOM_ENDPOINT")
	GitCustomEndpoint             = os.Getenv("TF_ACC_GIT_CUSTOM_ENDPOINT")
	IaaSCustomEndpoint            = os.Getenv("TF_ACC_IAAS_CUSTOM_ENDPOINT")
	KMSCustomEndpoint             = os.Getenv("TF_ACC_KMS_CUSTOM_ENDPOINT")
	LoadBalancerCustomEndpoint    = os.Getenv("TF_ACC_LOADBALANCER_CUSTOM_ENDPOINT")
	LogMeCustomEndpoint           = os.Getenv("TF_ACC_LOGME_CUSTOM_ENDPOINT")
	MariaDBCustomEndpoint         = os.Getenv("TF_ACC_MARIADB_CUSTOM_ENDPOINT")
	ModelServingCustomEndpoint    = os.Getenv("TF_ACC_MODELSERVING_CUSTOM_ENDPOINT")
	AuthorizationCustomEndpoint   = os.Getenv("TF_ACC_authorization_custom_endpoint")
	MongoDBFlexCustomEndpoint     = os.Getenv("TF_ACC_MONGODBFLEX_CUSTOM_ENDPOINT")
	OpenSearchCustomEndpoint      = os.Getenv("TF_ACC_OPENSEARCH_CUSTOM_ENDPOINT")
	ObservabilityCustomEndpoint   = os.Getenv("TF_ACC_OBSERVABILITY_CUSTOM_ENDPOINT")
	ObjectStorageCustomEndpoint   = os.Getenv("TF_ACC_OBJECTSTORAGE_CUSTOM_ENDPOINT")
	PostgresFlexCustomEndpoint    = os.Getenv("TF_ACC_POSTGRESFLEX_CUSTOM_ENDPOINT")
	RabbitMQCustomEndpoint        = os.Getenv("TF_ACC_RABBITMQ_CUSTOM_ENDPOINT")
	RedisCustomEndpoint           = os.Getenv("TF_ACC_REDIS_CUSTOM_ENDPOINT")
	ResourceManagerCustomEndpoint = os.Getenv("TF_ACC_RESOURCEMANAGER_CUSTOM_ENDPOINT")
	ScfCustomEndpoint             = os.Getenv("TF_ACC_SCF_CUSTOM_ENDPOINT")
	SecretsManagerCustomEndpoint  = os.Getenv("TF_ACC_SECRETSMANAGER_CUSTOM_ENDPOINT")
	SQLServerFlexCustomEndpoint   = os.Getenv("TF_ACC_SQLSERVERFLEX_CUSTOM_ENDPOINT")
	ServerBackupCustomEndpoint    = os.Getenv("TF_ACC_SERVER_BACKUP_CUSTOM_ENDPOINT")
	ServerUpdateCustomEndpoint    = os.Getenv("TF_ACC_SERVER_UPDATE_CUSTOM_ENDPOINT")
	ServiceAccountCustomEndpoint  = os.Getenv("TF_ACC_SERVICE_ACCOUNT_CUSTOM_ENDPOINT")
	SKECustomEndpoint             = os.Getenv("TF_ACC_SKE_CUSTOM_ENDPOINT")
)
View Source
var (
	// TestAccProtoV6ProviderFactories is 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.
	TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
		"stackitprivatepreview": providerserver.NewProtocol6WithError(stackit.New("test-version")()),
	}

	// TestEphemeralAccProtoV6ProviderFactories is 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.
	//
	// See the Terraform acceptance test documentation on ephemeral resources for more information:
	// https://developer.hashicorp.com/terraform/plugin/testing/acceptance-tests/ephemeral-resources
	TestEphemeralAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
		"stackitprivatepreview": providerserver.NewProtocol6WithError(stackit.New("test-version")()),
		"echo":                  echoprovider.NewProviderServer(),
	}

	// E2ETestsEnabled checks if end-to-end tests should be run.
	// It is enabled when the TF_ACC environment variable is set to "1".
	E2ETestsEnabled = os.Getenv("TF_ACC") == "1"
	// OrganizationId is the id of organization used for tests
	OrganizationId = os.Getenv("TF_ACC_ORGANIZATION_ID")
	// ProjectId is the id of project used for tests
	ProjectId = os.Getenv("TF_ACC_PROJECT_ID")
	Region    = os.Getenv("TF_ACC_REGION")
	// ServiceAccountFile is the json file of the service account
	ServiceAccountFile = os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE")
	// ServerId is the id of a server used for some tests
	ServerId = getenv("TF_ACC_SERVER_ID", "")
	// TestProjectParentContainerID is the container id of the parent resource under which projects are created as part of the resource-manager acceptance tests
	TestProjectParentContainerID = os.Getenv("TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID")
	// TestProjectParentUUID is the uuid of the parent resource under which projects are created as part of the resource-manager acceptance tests
	TestProjectParentUUID = os.Getenv("TF_ACC_TEST_PROJECT_PARENT_UUID")
	// TestProjectServiceAccountEmail is the e-mail of a service account with admin permissions on the organization under which projects are created as part of the resource-manager acceptance tests
	TestProjectServiceAccountEmail = os.Getenv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL")
	// TestProjectUserEmail is the e-mail of a user for the project created as part of the resource-manager acceptance tests
	// Default email: acc-test@sa.stackit.cloud
	TestProjectUserEmail = getenv("TF_ACC_TEST_PROJECT_USER_EMAIL", "acc-test@sa.stackit.cloud")
	// TestImageLocalFilePath is the local path to an image file used for image acceptance tests
	TestImageLocalFilePath = getenv("TF_ACC_TEST_IMAGE_LOCAL_FILE_PATH", "default")
)

Functions

func ActivateEnvironmentHttpMocks

func ActivateEnvironmentHttpMocks()

func AuthorizationProviderConfig

func AuthorizationProviderConfig() string

func CdnProviderConfig

func CdnProviderConfig() string

func CleanupTemporaryHome

func CleanupTemporaryHome(tempHomePath string, t *testing.T)

CleanupTemporaryHome cleanup the temporary home and reset the environment variable

func ConvertConfigVariable

func ConvertConfigVariable(variable config.Variable) string

func CreateDefaultLocalFile

func CreateDefaultLocalFile() os.File

CreateDefaultLocalFile is a helper for local_file_path. No real data is created

func CreateTemporaryHome

func CreateTemporaryHome(createValidCredentialsFile bool, t *testing.T) string

CreateTemporaryHome create temporary home and initialize the credentials file as well

func DnsProviderConfig

func DnsProviderConfig() string

func GetHomeEnvVariableName

func GetHomeEnvVariableName() string

GetHomeEnvVariableName Helper function to obtain the home directory on different systems. Based on os.UserHomeDir().

func GetTestProjectServiceAccountJson

func GetTestProjectServiceAccountJson(path string) string

func GitProviderConfig

func GitProviderConfig() string

func IaaSProviderConfig

func IaaSProviderConfig() string

func IaaSProviderConfigWithBetaResourcesEnabled

func IaaSProviderConfigWithBetaResourcesEnabled() string

func IaaSProviderConfigWithExperiments

func IaaSProviderConfigWithExperiments() string

func KMSProviderConfig

func KMSProviderConfig() string

func LoadBalancerProviderConfig

func LoadBalancerProviderConfig() string

func LogMeProviderConfig

func LogMeProviderConfig() string

func MariaDBProviderConfig

func MariaDBProviderConfig() string

func ModelServingProviderConfig

func ModelServingProviderConfig() string

func MongoDBFlexProviderConfig

func MongoDBFlexProviderConfig() string

func ObjectStorageProviderConfig

func ObjectStorageProviderConfig() string

func ObservabilityProviderConfig

func ObservabilityProviderConfig() string

func OpenSearchProviderConfig

func OpenSearchProviderConfig() string

func PostgresFlexProviderConfig

func PostgresFlexProviderConfig(saFile string) string

func RabbitMQProviderConfig

func RabbitMQProviderConfig() string

func RedisProviderConfig

func RedisProviderConfig() string

func ResStr

func ResStr(prefix, resource, name string) string

func ResourceManagerProviderConfig

func ResourceManagerProviderConfig() string

func ResourceNameWithDateTime

func ResourceNameWithDateTime(name string) string

func SKEProviderConfig

func SKEProviderConfig() string

func SQLServerFlexProviderConfig

func SQLServerFlexProviderConfig(saFile string) string

func ScfProviderConfig

func ScfProviderConfig() string

func SecretsManagerProviderConfig

func SecretsManagerProviderConfig() string

func ServerBackupProviderConfig

func ServerBackupProviderConfig() string

func ServerUpdateProviderConfig

func ServerUpdateProviderConfig() string

func ServiceAccountProviderConfig

func ServiceAccountProviderConfig() string

func SetTemporaryHome

func SetTemporaryHome(tempHomePath string)

SetTemporaryHome Function to overwrite the home folder

func Setup

func Setup()

func StringFromTemplate

func StringFromTemplate(tplFile string, data any) (string, error)

func StringFromTemplateMust

func StringFromTemplateMust(tplFile string, data any) string

func TestName

func TestName() string

Types

This section is empty.

Jump to

Keyboard shortcuts

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