testutil

package
v0.93.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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){
		"stackit": 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){
		"stackit": 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")
	// 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")

	ALBCustomEndpoint             = customEndpointConfig{/* contains filtered or unexported fields */}
	ALBCertCustomEndpoint         = customEndpointConfig{/* contains filtered or unexported fields */}
	CdnCustomEndpoint             = customEndpointConfig{/* contains filtered or unexported fields */}
	DnsCustomEndpoint             = customEndpointConfig{/* contains filtered or unexported fields */}
	EdgeCloudCustomEndpoint       = customEndpointConfig{/* contains filtered or unexported fields */}
	GitCustomEndpoint             = customEndpointConfig{/* contains filtered or unexported fields */}
	IaaSCustomEndpoint            = customEndpointConfig{/* contains filtered or unexported fields */}
	KMSCustomEndpoint             = customEndpointConfig{/* contains filtered or unexported fields */}
	LoadBalancerCustomEndpoint    = customEndpointConfig{/* contains filtered or unexported fields */}
	LogMeCustomEndpoint           = customEndpointConfig{/* contains filtered or unexported fields */}
	LogsCustomEndpoint            = customEndpointConfig{/* contains filtered or unexported fields */}
	MariaDBCustomEndpoint         = customEndpointConfig{/* contains filtered or unexported fields */}
	ModelServingCustomEndpoint    = customEndpointConfig{/* contains filtered or unexported fields */}
	AuthorizationCustomEndpoint   = customEndpointConfig{/* contains filtered or unexported fields */}
	MongoDBFlexCustomEndpoint     = customEndpointConfig{/* contains filtered or unexported fields */}
	OpenSearchCustomEndpoint      = customEndpointConfig{/* contains filtered or unexported fields */}
	ObservabilityCustomEndpoint   = customEndpointConfig{/* contains filtered or unexported fields */}
	ObjectStorageCustomEndpoint   = customEndpointConfig{/* contains filtered or unexported fields */}
	PostgresFlexCustomEndpoint    = customEndpointConfig{/* contains filtered or unexported fields */}
	RabbitMQCustomEndpoint        = customEndpointConfig{/* contains filtered or unexported fields */}
	RedisCustomEndpoint           = customEndpointConfig{/* contains filtered or unexported fields */}
	ResourceManagerCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */}
	ScfCustomEndpoint             = customEndpointConfig{/* contains filtered or unexported fields */}
	SecretsManagerCustomEndpoint  = customEndpointConfig{/* contains filtered or unexported fields */}
	SQLServerFlexCustomEndpoint   = customEndpointConfig{/* contains filtered or unexported fields */}
	ServerBackupCustomEndpoint    = customEndpointConfig{/* contains filtered or unexported fields */}
	ServerUpdateCustomEndpoint    = customEndpointConfig{/* contains filtered or unexported fields */}
	SFSCustomEndpoint             = customEndpointConfig{/* contains filtered or unexported fields */}
	ServiceAccountCustomEndpoint  = customEndpointConfig{/* contains filtered or unexported fields */}
	TokenCustomEndpoint           = customEndpointConfig{/* contains filtered or unexported fields */}
	SKECustomEndpoint             = customEndpointConfig{/* contains filtered or unexported fields */}
)

Functions

func CheckAttrHasPrefix added in v0.92.0

func CheckAttrHasPrefix(prefix string) resource.CheckResourceAttrWithFunc

CheckAttrHasPrefix returns a CheckResourceAttrWithFunc that validates whether an attribute value starts with the given prefix.

func ConvertConfigVariable added in v0.52.0

func ConvertConfigVariable(variable config.Variable) string

func CreateDefaultLocalFile added in v0.43.1

func CreateDefaultLocalFile() os.File

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

func GetTestProjectServiceAccountToken added in v0.57.0

func GetTestProjectServiceAccountToken(path string) string

func ResourceNameWithDateTime

func ResourceNameWithDateTime(name string) string

Types

type ConfigBuilder added in v0.90.0

type ConfigBuilder struct {
	// contains filtered or unexported fields
}

func NewConfigBuilder added in v0.90.0

func NewConfigBuilder() *ConfigBuilder

NewConfigBuilder creates a new ConfigBuilder with region eu01 as default. All custom endpoints defined in TF_ACC_*_CUSTOM_ENDPOINT env vars are also set.

func (*ConfigBuilder) BuildClientOptions added in v0.90.0

func (b *ConfigBuilder) BuildClientOptions(service customEndpointConfig, setRegion bool) []sdkConf.ConfigurationOption

func (*ConfigBuilder) BuildProviderConfig added in v0.90.0

func (b *ConfigBuilder) BuildProviderConfig() string

func (*ConfigBuilder) CustomEndpoint added in v0.90.0

func (b *ConfigBuilder) CustomEndpoint(endpoint customEndpointConfig, url string) *ConfigBuilder

func (*ConfigBuilder) EnableBetaResources added in v0.90.0

func (b *ConfigBuilder) EnableBetaResources(enable bool) *ConfigBuilder

func (*ConfigBuilder) Experiments added in v0.90.0

func (b *ConfigBuilder) Experiments(experiments ...Experiment) *ConfigBuilder

func (*ConfigBuilder) Region added in v0.90.0

func (b *ConfigBuilder) Region(region string) *ConfigBuilder

func (*ConfigBuilder) ServiceAccountToken added in v0.90.0

func (b *ConfigBuilder) ServiceAccountToken(token string) *ConfigBuilder

type Experiment added in v0.90.0

type Experiment string
const (
	ExperimentRoutingTables Experiment = "routing-tables"
	ExperimentNetwork       Experiment = "network"
	ExperimentIAM           Experiment = "iam"
)

type MockResponse added in v0.83.0

type MockResponse struct {
	StatusCode  int
	Description string
	ToJsonBody  any
	Handler     http.HandlerFunc
}

MockResponse represents a single response that the MockServer will return for a request. If `Handler` is set, it will be used to handle the request and the other fields will be ignored. If `ToJsonBody` is set, it will be marshaled to JSON and returned as the response body with content-type application/json. If `StatusCode` is set, it will be used as the response status code. Otherwise, http.StatusOK will be used.

type MockServer added in v0.83.0

type MockServer struct {
	Server *httptest.Server
	// contains filtered or unexported fields
}

func NewMockServer added in v0.83.0

func NewMockServer(t *testing.T, responses ...MockResponse) *MockServer

NewMockServer creates a new simple mock server that returns `responses` in order for each request. Use the `Reset` method to reset the response order and set new responses.

func (*MockServer) Reset added in v0.83.0

func (m *MockServer) Reset(responses ...MockResponse)

func (*MockServer) ServeHTTP added in v0.83.0

func (m *MockServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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